4

i am using uniform js for changing the background images of checkbox, radio buttons, select box. For this i include jquery file, uniform library js file and another thing is a function of uniform js for initializing the function as

$(function(){
   $("input, select, textarea, button").uniform();
});

Here i got one issue, i want to clear this function at the specific portion of the content where i do not want uniform function. then what procedure do i adopt for solving my problem?

I do not have jsfiddle code for this code. If you need it i will let you know.

Barmar
  • 741,623
  • 53
  • 500
  • 612
Hassaan
  • 328
  • 1
  • 2
  • 9

3 Answers3

10

Just use the .not() function and set a class on items that you wish to omit the uniform() logic.

DOM:

<!-- This gets it -->
<select>
   <option>Foo</option>
</select>

<!-- This doesn't -->
<select class="noUniform">
    <option>Bar</option>
</select>

JS:

$(function(){
   $("input, select, textarea, button").not('.noUniform').uniform();
});
AlienWebguy
  • 76,997
  • 17
  • 122
  • 145
  • Will the bind function works here ?? or either i prefer your piece of code. – Hassaan Mar 11 '13 at 21:42
  • What if op has dozens or hundreds of elements that need the class applied? And would you agree that supporting this down the road becomes a problem, since new elements which are added that don't have this class attribute will have `uniform` applied? For that reason, I think a positive selector is almost always better than a negative one and here, the double-negative of `.not(.noUniform)` is semantically clumsy in my opinion. No offense intended. – Madbreaks Mar 11 '13 at 21:45
  • The simple fact that he's binding on tag names implies that they should be uniform by default, minus a handful of special cases. @Hassaan I don't see any binding here, just a function applied to the nodes. If you need it applied to nodes added after DOM ready, simply place the above logic in a function you can call after the new nodes are added. – AlienWebguy Mar 11 '13 at 21:50
  • 1
    Worked a charm. Thank you for providing this solution. – arcseldon Dec 04 '13 at 08:25
  • This link provides further info: https://github.com/pixelmatrix/uniform/issues/150 – arcseldon Dec 04 '13 at 08:54
1

the attribute data-no-uniform set as "true" do the job

fedeghe
  • 1,243
  • 13
  • 22
0

According to Prestashop 1.6.x there is already omitting uniform implemented in default theme:

.\themes\default-bootstrap\js\global.js

with using class .not_uniform

$("select.form-control,input[type='radio'],input[type='checkbox']").not(".not_uniform").uniform();