用Backbone.js替换时,带有queryui复选框按钮的内容会增加 [英] Content with queryui checkbox button grows when is replaced with Backbone.js
问题描述
我有下一个代码可以使用Backbone.js替换内容
I have the next code to replace content using Backbone.js
我不知道替换内容后复选框为什么会增加. 简而言之,我使用下面的代码来选中
I don't know why the checkbox button grows when the content is replaced. Simply, I use the next code to checkbox
$('.checkWeek').button();
推荐答案
我认为原因是因为您每次单击都会不断调用$('.checkWeek').button();
,因此JQuery做一些有趣的事情,并在span
内添加了span
,导致尺寸增大.
I think the reason is because you keep calling the $('.checkWeek').button();
on every click so JQuery does something funny and adds a span
within a span
which causes the size to grow.
一个简单的解决方法是,如果按钮已经存在(或显示),则不调用$('.checkWeek').button();
A simple fix is to not call the $('.checkWeek').button();
if the button already exists (or shown)
// if button already exists then dont add it again.
if(!$('label[for=checkWeekM]').hasClass('ui-button'))
$('.checkWeek').button();
查看此处: http://jsfiddle.net/Thxtr/3/
这篇关于用Backbone.js替换时,带有queryui复选框按钮的内容会增加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!