Skip to content

Commit

Permalink
Fixes AudithSoftworks#80: Wrapper div should inherit classes from ori…
Browse files Browse the repository at this point in the history
…ginal input elements

Applies to:
 - select (non-multiline)
 - radio
 - checkbox
 - file input

Has the side effect that there is now no way to specify a class to be left on the original select or input element.

A few possible solutions:
 - Leave the class on the element all the time
    - Could result in style conflicts (i.e. styling meant for wrapper div also applies to hidden select/input element.
 - Add an option to either leave the class on or remove it.
 - Take the classes off, but rename them with "uniform-" prefix, similar to how id's are inherited.
 - Use a data attribute such as "data-uniform-class" to specify classes that should be added to the wrapper div
    - Wouldn't work with jQuery < 1.4.3
    - Would require different class definitions for regular inputs that don't use wrapper divs and inputs that do (i.e. class vs. data-uniform-class)
  • Loading branch information
ericfreese committed Feb 21, 2013
1 parent 1850e2c commit 6030616
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion jquery.uniform.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ Enjoy!
$div.addClass(divSpanConfig.divClass);
}

// Apply any specified classes to the created div
$div.addClass($el.attr("class"));

// Remove classes from the original element
$el.removeClass();

if (options.wrapperClass) {
$div.addClass(options.wrapperClass);
}
Expand Down Expand Up @@ -789,7 +795,7 @@ Enjoy!
}

ds = divSpan($el, options, {
divClass: (typeof options.selectClass === "function" ? options.selectClass.apply($el) : options.selectClass),
divClass: options.selectClass,
spanHtml: ($el.find(":selected:first") || $el.find("option:first")).html(),
spanWrap: "before"
});
Expand Down

0 comments on commit 6030616

Please sign in to comment.