Sam3k
Sam3k

Reputation: 950

JQuery JEditable Plugin On Focus Notify Callback Function

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

Answers (3)

Mika Tuupola
Mika Tuupola

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

Shawn J. Goff
Shawn J. Goff

Reputation: 4755

By default, the plugin works on the click event, so try $(selector).editable(options).click(function () {foo();});

Upvotes: 0

riotera
riotera

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

Related Questions