Question

Uniform is a jQuery plugin for styling up the forms. I use it on my project and there I have a case where I need to turn off this plugin and turn on later.

You turn on plugin in a following way (one of the ways): $("input, textarea, select, button").uniform();

If you want to turn off a plugin (bring back old styles) you do: $.uniform.restore();

It works fine, but not on button, submit, or reset. When restoring a value of these inputs comes out and finds a place at the left side of original button.

Here is a jsFiddle link for you to see a demo: jsFiddle uniform.js problem

I tried to solve this but without luck. Please help me out. Thanks.

Était-ce utile?

La solution

Well, here's a very crude fix for this:

$.uniform._restore = $.uniform.restore;
$.uniform.restore  = function(elem) {
  if (elem === undefined) {
     elem = $($.uniform.elements);
  }
  $(elem).each(function() {
     if ($(this).is("button, :submit, :reset, input[type='button']")) {
       this[0].parentNode.firstChild.nodeValue = '';
     }
  });
  $.uniform._restore(elem);
};

As shown here, it works. But I'd rather fix this in the uniform source code (that's why it's hosted on github, afterall). )

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top