问题
is it possible to reset to original state after changing class and applying the jeditable plugin
say i have this example
<div class="non_edit" id="test1">test1</div>
<div class="non_edit" id="test2">test2</div>
and have this divs change class by this function
$('div.non_edit').addClass('edit').removeClass('non_edit');
and apply jeditable
$('.edit').editable('somepage.php');
now when i want to return to its 'non-editable' state i have this
$('div.edit').addClass('non_edit').removeClass('edit');
but still the 'changed' divs are editable, what im trying to do here is to set certain divs editable and non editable , and also if there are any suggestions on how to do this in another way is much appreciated
thanks
回答1:
$('div.edit').addClass('non_edit').removeClass('edit').unbind('click.editable');
This will do it (tested on jeditable site using console). All this is doing is unbinding the event so nothing fires. You must use the correct namespacing as well - my code above works on the default.
Hope that helps!
来源:https://stackoverflow.com/questions/4689271/jquery-jeditable-how-reset-to-non-editable-without-page-refresh