Search code examples
javascriptjqueryjeditable

How-to fix - jEditable being calledback 2x?


I am going crazy with jEditable... it appears that the callback is being called twice in my case, where I have an fnUpdate inside my table:

oTable.$("td.my_class").editable(function(value, settings) { 
    if (ifItsNumeber(value)) {
        console.log("It's a number.");

        var aPos = oTable.fnGetPosition( this );

        console.log("aPos: "+aPos);

        oTable.fnUpdate(qnttSL, aPos[0], aPos[1]));

        return(value);
    } else {
        console.log("It's not a NUMBER");

        return(null);    
    }

}, {
    width: '100%',
    onblur : 'submit'
});

What am I doing wrong?


Solution

  • For the callback to work it has to be used in the callback option of jEditable, after reading the documentation more intently... I think I misunderstood the use of the function builder, vs the Ajax call.

    oTable.$("td.my_class").editable(function(value, settings) { 
        if (ifItsNumeber(value)) {
            console.log("It's a number.");
            return(value);
        } else {
            console.log("It's not a NUMBER");
    
            return(null);    
        }
    
    }, {
        width: '100%',
        onblur : 'submit'
        callback: function(value){
                     var aPos = oTable.fnGetPosition( this );
                     oTable.fnUpdate(value, aPos[0], aPos[1]));
                  }
    
    });