Search code examples
jqueryfunctionjeditable

jeditable onblur function


I am using jeditable but want to use a function to save the data on the client. This works fine, but I also want to use a function to handle the onblur event. My code is as follows:

$('#answerlist li').editable(function(value, settings) {
            OnAnswerTextEdit(this, value);
            return (value);
        }, { onblur: function(value) {
            OnAnswerTextEdit(this, value);
        }
        });

It sort of works, but the jeditable edit window does not close following the onblur event. Does anyone know how I can close the edit session on loss of focus, or somehow grab my changes via a function when the edit textbox loses focus. I do not want to submit a form at any time - I want to keep all changes local. Thanks very much.


Solution

  • I used the following to solve the problem (used reset() to close the editor, but applied the changes 'manually' by setting the html:

    $('#answerlist li').editable(function(value, settings) {
                OnAnswerTextEdit(this, value);
                return (value);
            }
            , { onblur: function(value) {
                OnAnswerTextEdit(this, value);
                this.reset(value);
                $(this).html(value); 
                return (value); }
            });