1

having a bit of trouble with jeditable plugin for jquery and was hoping someone wiser than myself can help.

Essentially I am trying to trigger the editable function on mouseover and submit any changes on mouse leave... sounds simple but the mouse leave bit doesnt seem very well documented :( This is kinda what I have so far:

$('.content').live("mouseenter", function() {
    console.log("enter");

    $('.editable', $(this)).editable(function(value, settings) {
        //do stuff
    });

}).live("mouseleave", function() {
    console.log("leave");

    $('.editable', $(this)).editable(function(value, settings) {
        //stop doing stuff
    });
})

So anyone have any idea how I submit the editable content and reset the content when mousing out? It only seems to work with a click :(

lawlesscreation
  • 649
  • 1
  • 6
  • 15

2 Answers2

1

There is an onblur option, which allows you to specify the behaviour when the element being edited is blurred. To achieve what you are after, you could specify onblur: 'submit', and on mouseleave, you can make the element blur, e.g. $('.editable', this).blur().

William Niu
  • 15,798
  • 7
  • 53
  • 93
0

I would use mouseover and mouseout as suggested in the jQuery documentation like so:

$(".hoverme").live("mouseover mouseout", function(event) {
  if ( event.type == "mouseover" ) {
    // do something on mouseover
  } else {
    // do something on mouseout
  }
});
Hogan
  • 69,564
  • 10
  • 76
  • 117
  • thanks much tidier than my code, but its more the trigger event that im stuck on with the jeditable. I dont know how to trigger the submitting of then jeditable content on mouse out? – lawlesscreation Sep 10 '11 at 12:36
  • oh, you want to know how to submit a web form with javascript? http://stackoverflow.com/questions/133925/javascript-post-request-like-a-form-submit/133997#133997 – Hogan Sep 10 '11 at 12:54