JQuery Mobile refreshing复选框只工作一次 - .checkboxradio('refresh')问题 [英] JQuery Mobile refreshing checkbox works only once - .checkboxradio('refresh') issue
问题描述
我遇到了一个奇怪的问题。我有一个表的复选框列。我使用JQuery Mobile复选框。我想点击要关联的行,点击此行中的复选框。
JS:
$文档).on('pagecreate',function(event){
bindRowClick();
});
function bindRowClick(){
$('。productTable')。find('tr')。click(function(){
var chck = $(this)。 find('td.hyperLink')。find('input [type = checkbox]:first');
var chckStatus = chck.is(':checked');
alert(chckStatus 1: + chckStatus);
alert(!chckStatus:+!chckStatus);
chck.attr('checked',!chckStatus).checkboxradio()。checkboxradio('refresh');
alert(chckStatus 2:+ chck.is(':checked'));
});
}
HTML: c>< td class =hyperlink>
< fieldset data- controlgroupid =divCheckbox>
< asp:CheckBox runat =serverID =checkboxSelectCssClass =custom chckSelect
meta:resourcekey =checkboxSelectResource1/&
< asp:Label ID =lblForChckCssClass =lblForChckAssociatedControlID =checkboxSelectrunat =server
meta:resourcekey =lblForChckResource1/&
< / fieldset>
点击第1行时会发生什么选择到现在):
第一警报返回:chckStatus 1:false
第二警报返回:!chckStatus :true
第三次提醒返回:chckStatus 2:true
发生在我点击 SAME 行2次时(以前选中复选框):
第一警报返回:chckStatus 1:true
第二警报返回:!chckStatus:false
第三警报返回:chckStatus 2:false
现在的奇怪部分
再次在同一行 - 而不是选择复选框(像第一次)我有以下结果:
第一警告返回:chckStatus 1:true
pre>
第二警报返回:!chckStatus:false
第三警报返回:chckStatus 2:false
我发现可能连接到这个问题:
=h2_lin>解决方案而不是使用
.attr()
使用.prop c>然后
.checkboxradio('refresh')
。
I ran into a strange problem. I've got a table with a checkbox column. I'm using JQuery Mobile checkboxes. I want a click on a row to be associated with click on the checkbox in this row.
JS:
$(document).on('pagecreate', function (event) { bindRowClick(); }); function bindRowClick() { $('.productTable').find('tr').click(function () { var chck = $(this).find('td.hyperLink').find('input[type=checkbox]:first'); var chckStatus = chck.is(':checked'); alert("chckStatus 1: " + chckStatus); alert("!chckStatus: " + !chckStatus); chck.attr('checked', !chckStatus).checkboxradio().checkboxradio('refresh'); alert("chckStatus 2: " + chck.is(':checked')); }); }
HTML: this is inside
<td class="hyperlink">
<fieldset data-role="controlgroup" id="divCheckbox"> <asp:CheckBox runat="server" ID="checkboxSelect" CssClass="custom chckSelect" meta:resourcekey="checkboxSelectResource1" /> <asp:Label ID="lblForChck" CssClass="lblForChck" AssociatedControlID="checkboxSelect" runat="server" meta:resourcekey="lblForChckResource1" /> </fieldset>
What's happening with when I click on row 1 time (checkbox was not selected until now):
first alert returns: "chckStatus 1: false" second alert returns: "!chckStatus: true" third alert returns: "chckStatus 2: true"
What's happening with when I click on the SAME row 2 time (checkbox was selected previously):
first alert returns: "chckStatus 1: true" second alert returns: "!chckStatus: false" third alert returns: "chckStatus 2: false"
And now the strange part
When I click again on the same row - instead of selecting the checkbox (like the first time) I've got the following result:
first alert returns: "chckStatus 1: true" second alert returns: "!chckStatus: false" third alert returns: "chckStatus 2: false"
What I found that might be connected to this issue: Previously working ".checkboxradio('refresh')" now broken in a3
解决方案Instead of using
.attr()
use.prop()
and then.checkboxradio('refresh')
.
这篇关于JQuery Mobile refreshing复选框只工作一次 - .checkboxradio('refresh')问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!