jQuery In Place Editorをいじってみましたが、適切に無効にする方法がわかりません。以下は私がこれまでに持っているコードです。
toggle
リンクのリストでプラグイン機能を初期化および終了するためにjQueryメソッドを使用しています。以下のコードには、おそらく私の問題とは関係のない余分なビットがいくつかありますが、念のために残しておきます。
問題は、以下のコードが最初の2クリックで期待どおりに機能することです(つまり、1回目のクリック-editInPlaceプラグインを有効にし、2回目のクリック-無効にします)が、3回目のクリックでインプレース編集機能を再度有効にしません。
なぜ何かアイデアはありますか?
(shoppingList.editButton).toggle(function() {
(shoppingList.editButton).attr('value', 'Finish editing');
(shoppingList.$ingrLinks).unbind('click', shoppingList.ingredients) // disable some functionality on links
.addClass('inplace-editor') // add class to links I want to be editable
.removeAttr('href') // make links unclickable
.editInPlace({ // editInPlace plugin initialized
url: 'http://localhost:8000/edit-ingredient/',
show_buttons: true
});
}, function() {
(shoppingList.editButton).attr('value', 'Edit items');
(shoppingList.$ingrLinks).bind('click', shoppingList.ingredients) // bring back the functionality previously removed
.removeClass('inplace-editor') // remove the class from links that were editable
.attr('href', '#') // make the links clickable again
.unbind('.editInPlace') // remove editInPlace plugin functionality
;
});