jeudi 26 mai 2016

If statement true but not executed

The following piece of javascript code does not what I expect. It's the code that is executed on succes of an ajax call but: although in some rounds of the $.each value1.html_id and redraw or reload are equal (and they are both strings) the if(){} code does never get executed. What am I missing here?

The console.log() outside the if statements gets executed and I can see that the values are the same, but the code in the {} of the if never gets executed

success: function(result) {
    activaTab(tab_id);
    $.each(tables, function(key, value1) {
        console.log(value1.html_id + redraw + reload)
        if (value1.html_id == redraw) {
            console.log('works');
            value1.table.columns.adjust().draw();
        }
        if (value1.html_id == reload) {
            console.log('works2');
            value1.table.ajax.reload(null, false);
        }
    });
}

The console looks like this everytime (being 324 the line outside the ifs)

scr_table2.js:324 scr-tablescr_tablescr_table1
scr_table2.js:324 scr-table1scr_tablescr_table1
scr_table2.js:324 scr-table2scr_tablescr_table1
scr_table2.js:324 scr-table3scr_tablescr_table1

Aucun commentaire:

Enregistrer un commentaire