I am using jQuery .editable()
to make a <p>
editable.
What I am trying to do is to select the text already in the element when a user clicks on it to edit.
I've read that OnEdit
is the option that I should use to call a function every time a user clicks on an .editable object, but for some reason my test alert()
isn't being called at all.
JS:
this.$('.name').editable(function (value, settings) {
if (value.length > 50)
value = value.substr(0, 50);
that.model.save("name", value);
return(value);
}, HotelNinjas.Settings.textPluginData);
this.showRoomType();
return this;
},
...
onEdit: function (e) {
alert("edit"); // <<--- DOESN'T GET CALLED
}
});
HTML:
<p class="name">Some Text</p>
Please post a bit more code, or even better, create a jsFiddle. In any case, try using this instead for alerting on edit.
$('.name').on('edit',function (e) {
alert("edit");
});
Does your javascript console output any errors by chance?