I would like to be able to click a button to enable a text input for editing and then click it again when I am done which will fire off the ajax to save it. I am reading the doc's for on() and off() and am unable to get this to work. Here is the code:
<div>
<button>Click Me!</button>
</div>
$('button').click(function(){
//add a class as a handle for the save event later
$(this).addClass('test').text('Click to Save');
//remove the click event from the button
$(this).off('click');
alert("This event is off!");
//do other stuff like disable the input (no help needed)
});
$("div").on("click","button.test" function(){
alert("This event works!");
//do ajax stuff here (no help needed)
//turn this event off and turn the other back on??
});