【发布时间】:2012-01-23 21:46:01
【问题描述】:
我正在为 jQuery UI 编写自己的 CSS。
基本上,我需要为单选按钮、复选框和常规按钮设置不同的样式。
这里的问题是jQuery的类添加到假小部件没有指定它是什么类型的按钮。
例如,假设我们有这样的代码:
<input type="checkbox" name="location[]" id="location1" value="Somewhere" />
<label for="location1">Somewhere</label>
<script type="text/javascript">
$(document).ready(function(){
jQuery('input').button();
});
</script>
jQuery 将这两个元素转换为:
<input type="checkbox" name="location[]" id="location1" value="Somewhere"
class="ui-helper-hidden-accessible">
<label for="location1" aria-pressed="false" role="button" aria-disabled="false"
class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only">
<span class="ui-button-text">Somewhere</span>
</label>
如您所见,修改后的标签和生成的跨度没有任何类告诉我它是一个复选框(或单选/按钮)。
理想的解决方案是基于我没有注意到的一些课程。第二个最好的解决方案是对 jQuery UI 进行猴子补丁,以便为这些输入添加更好的类。最终可能的解决方案是破解 jQuery 文件……尽管我真的很想避免这种情况。
请注意,我们不会容忍任何形式的狂热、非建设性的 cmet 和类似的答案。问题是 jQuery UI,我不想听到 mootools、extjs 或任何你想到的时髦的 l33t 库。
【问题讨论】:
标签: jquery css jquery-ui jquery-ui-theme