javascript - jQuery Datepicker clone has opposite of expected effect -
javascript - jQuery Datepicker clone has opposite of expected effect -
i noticed odd in jquery-ui datepicker:
as seen in fiddle, clone of datepicker doesn't retain events want, append does!
<p>date: <div id="datepicker"></div> <p><p><p> <div id="clone"></div> <div id="append"></div> </p>
js:
var obj = { ... onselect: function(thing) { console.log(thing); $(this).attr('data-thing',thing); } }; $("#datepicker").datepicker(obj); $('#clone').append($("#datepicker").clone(true)); $('#append').append($('#datepicker'));
i had case each module has different sections on page, each of has settings (including date) kept same within sections.
even cloning existing settings, removing original, , appending selected section, messes callback, has "this" root ($(this).parent().parent().parent()...
) of null
, not window.
is unexpected in jquery-ui picker, or going wrong way? have feeling backbone js may have improve way maintain info outside of dom, there recommended pattern this? also, how datepicker retain events on append?
javascript jquery jquery-ui backbone.js datepicker
Comments
Post a Comment