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();
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();
I'm guessing that
$('.checkWeek').button()
only needs to be called once per.checkweek
element, or maybe just once in total.If so then possible workarounds would be :
$('.checkWeek').button()
conditionally (though I'm not sure what the test might be).$('.checkWeek')
selector more selective, ie select only the freshly added element.$('.checkWeek').button('destroy').button()
(or similar - you will have to search through the plugin's API documentation).Without a more complete understanding of the app (and the plugins), I can't tell which of these possibilities is most appropriate.
I think the reason is because you keep calling the
$('.checkWeek').button();
on every click so JQuery does something funny and adds aspan
within aspan
which causes the size to grow.A simple fix is to not call the
$('.checkWeek').button();
if the button already exists (or shown)Look here: http://jsfiddle.net/Thxtr/3/
At the moment code stores the templates in
div
tags - every time you callbutton
the template is modified. You can avoid that by using ascript
tag with typetext/template
so that it won't be executed as Javascript.Rigth now:
Change to:
With the Javascript unchanged the template will not be found. So you also have to update this line:
With the requirement for the template to be inside a div removed:
Working fiddle