javascript - Delete a DOM element and its associated jquery plugin and data -
first, i'm using jquery plugin on element, lets
$('#myelement').useplugin();
.second, want destroy original element , plugin variables etc may still exist in js.
third, create new
#myelement
, redo$('#myelement').useplugin();
.
i'm having trouble step #2. when $('#myelement').remove()
, there residual strange behavior when recreate element , instantiate plugin.
fyi: plugin i'm having trouble with: http://mindmup.github.io/editable-table/. if create table, make editable, works fine.
but if delete table, recreate table, make editable, strange behavior fields editable, when hit "enter", value not save , error uncaught typeerror: cannot read property 'trigger' of undefined
.
i modify line in plugin:
https://github.com/mindmup/editable-table/blob/master/mindmup-editabletable.js#l115
to:
$(window).on('resize.mindmup', function () {
now, when want remove event, remove namespace.
$(window).off("resize.mindmup");
continue removing , re-creating table, use above line remove window resize event before re-initializing plugin.
Comments
Post a Comment