Jquery - Jeditable: How Reset to non-editable without page refresh

旧城冷巷雨未停 提交于 2019-12-10 16:37:52

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!