jQuery的统一复选框不(UN)检查 [英] jQuery Uniform Checkbox does not (un)check
问题描述
我使用 jQuery的统一以风格输入/选择欧洲列车控制系统。然而,该复选框已停止工作。我是从Ajax调用发送追加
数据。一旦它的加载,我用 $ uniform.update。(输入:复选框)
更新新的HTML。当试图(取消)选中它只能一次输入。如果我想要(联合国)检查一遍,它不会改变的。
I am using jQuery Uniform to style inputs/selects etcs. However, the checkbox has stopped working. I am appending
data sent from an ajax call. Once it's loaded, I use $.uniform.update("input:checkbox")
to update the new html. When attempting to (un)check the input it works only once. If I want to (un)check it again, it doesn't change at all.
我试图改变统一的Javascript 让所有的动作(即点击
,焦点
,模糊
等)都在 .live
功能。 (即 .live(点击,
)。这只是从工作停止任何东西。
I've attempted changing the Uniform Javascript so that all the actions (ie. click
, focus
, blur
etc) are under the .live
function. (ie. .live("click",
). This just stops anything from working.
更新:的
我已经通过统一JS完全读取和发现了一个问题:
I've read through the Uniform JS entirely and discovered a problem:
if(!$(elem).attr("checked")){
//box was just unchecked, uncheck span
spanTag.removeClass(options.checkedClass);
}else{
//box was just checked, check span.
spanTag.addClass(options.checkedClass);
}
在 .attr(选中)
语法失败。它总是返回false。为什么?我不知道。除了这一点,它不更新原始的输入
要么删除检查
属性或设置检查
属性。
The .attr("checked")
syntax fails. It will always return false. Why? I don't know. As well as this, it doesn't update the original input
to either remove the checked
attribute or to set the checked
attribute.
我已经通过官网运行,并发现它不更新的复选框输入。所以,这不只是我的XP
I've run through the official website and found it doesn't update the checkbox input. So it's not just me xP
我GOOGLE了一下周围,发现各种方法来检查,如果一个复选框被选中但下面的方法失败:
I've Googled around a bit and found various methods for checking if a checkbox is checked however the following methods fail:
if ($(elem).attr("checked")) // The original.
if ($(elem).attr("checked") == true)
if ($(elem).is(":checked"))
if ($(elem).checked)
// and:
var check = $(elem).match(/checked=/);
if (check == null)
指导言pciated非常AP $ P $〜:3
Words of guidance are very much appreciated~ :3
推荐答案
这是因为 UniformJs
需要更新您的修改对军装元素如果你需要动态的形式变化值:
SIMPLE SOLUTION
This is because UniformJs
requires that you update your modification on uniform elements if you need to change values on the form dynamically:
$('#checkbox').prop('checked',true);
$.uniform.update();
修改
如果您希望更新的 #checkbox
仅
$('#checkbox').prop('checked',true);
$.uniform.update('#checkbox');
这篇关于jQuery的统一复选框不(UN)检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!