Reputation: 950
I want to attach and event to the Jeditable Input box as soon as it gets created. There is an "onblur" but no onfocus as far as I can tell. Does anyone know a fast approach to do this?
Upvotes: 0
Views: 2026
Reputation: 20377
There's more than one way to do it but custom inputs are one. You could do something like:
$.editable.addInputType('textarea_hover', {
element : $.editable.types.textarea.element,
plugin : function(settings, original) {
$('textarea', this).bind('focus', function() {
/* Do something on focus. */
});
}
});
And then call Jeditable like:
$('.edit_area').editable('http://www.example.com/save.php', {
type : 'textarea_hover',
cancel : 'Cancel',
submit : 'OK'
});
Upvotes: 2
Reputation: 4755
By default, the plugin works on the click event, so try $(selector).editable(options).click(function () {foo();});
Upvotes: 0
Reputation: 1613
Depending on what you want to do, you could bind your click event to the editable elements instead of onfocus:
$(document).ready(function() {
$('.edit').editable('http://www.example.com/save.php');
$('.edit').click(function () { ... }
});
Upvotes: 0