Search code examples
jeditable

Jeditable: muliple events



how can we implement a multiple event in jeditable, i want to bind two events for a certain div, like dblclick and Enter key

$('.edit').editable('some.php', {
        event     : "dblclick",
        tooltip   : "Double click or press Enter Key to edit..."
    });

thanks


Solution

  • Well obviously, this is a property managed by the jEditable script, so your only solution would be to dig in jEditable.js and add another possibility for the event property, which would include the events of your liking ;)

    GL - I'm about to do just the same right now. - I'll post some info when I'm done.

    Ok so it was pretty easy --

    Two changes in the jquery.jeditable.mini.js

    find and replace :

    $(this).bind(settings.event,function(e){if(true===$(this).data('disabled.editable')){return;}
    

    with

    var eventlist=settings.event.split(',');$(this).bind(eventlist[0],function(e){if(true===$(this).data('disabled.editable')){return;}
    

    And then, at the end of the bound function -->

    find and replace

    $(self).attr('title',settings.tooltip);return false;});});
    

    with

    for(z=1;z<eventlist.length;z++){
    var funcname_of_no_collide_doom=eventlist[0];
    $(this).bind(eventlist[z],function(){$(this)[funcname_of_no_collide_doom]();});
    

    }

    And tadaam you just need to set the event property using a list of valid jQuery events, like event : 'dblclick,click,blur,tomato'

    Actually that mod was funny ... but the real simple solution is offered by jQuery directly :

    http://api.jquery.com/bind/

    rtfm --