views:

523

answers:

1

Hi everyone !!!

I have a problem with the livequery plugin Version: 1.0.3.

Watch this code:

$('#'+$(celDiv).find('input').attr('id')).livequery('blur',function(){
    var idProduct = $('#idProduct').val();
    var idSupplier = $('#idSupplier').val();
    var lotNumber = $('#lotNumber').val();
    var idSpecification = $('#idSpecification').val();
    var version = $('#version').val();
    var idItemAnalysis = id;
    var seqItemAnalysis = $(celDiv).parents('tr').find("td").eq(5).text();
    var operator = $(celDiv).parents('tr').find("td").eq(1).text();
    var val = $('#'+$(celDiv).find('input').attr('id')).val();

    if(val != null)
    {
        if((operator != '=>' && operator != '<=' ) && !isNaN(val.replace(',','.')))
        {
            $.post('/Operations/SaveAnalysisResults',{
                idProduct: idProduct,
                idSupplier: idSupplier,
                lotNumber: lotNumber,
                idSpecification: idSpecification,
                version: version,
                idItemAnalysis: idItemAnalysis,
                seqItemAnalysis: seqItemAnalysis,
                val: val
            });
            gridResultsAnalysis.flexReload();
        }
        else{
            alert("For this operation, the value must be numerical");
            $('#'+$(celDiv).find('input').attr('id')).val('');
        }
    }
});

After blur event, the livequery call is executed more than more, occurs problem in my data consistency.

For solution, I created a boolean variable to know if this code already was executed, but I think that this solution is a alternative solution.

Someone have other solution? The livequery plugin have a bug?

Thank you everyone !!!

+1  A: 

You can now do this in jQuery core with 1.4.1+ like this:

$(celDiv).find('input').live('blur', function(){

Also your calls like this:

$('#'+$(celDiv).find('input').attr('id')).val();

Can just be:

$(celDiv).find('input').val();

Or, inside your function:

$(this).val();
Nick Craver