jquery - Can't get dimensions of AJAX data on subsequent calls -
i'm think i'm going mad.
all want dimensions of data loaded via ajax regardless of how many times call made. works fine first time, value of 0 each subsequent call - despite fact appears on page, 1 expect.
// ajax part function getdetails(request){ $placehold.empty(); return jq.get(request); }; // filter & render ajax data function renderdata(data){ var endresult = $(data).find('#productdetails'); endresult.fadeto(0,0).appendto($placehold); $placehold.removeclass('loading'); endresult.fadeto(300,1); // <- added per request // console log uncalled data works fine // called again, 0 every single time console.log( jq('#anyelementinajaxdata').outerheight(false) ); }; // click handler jq('#slides').on('click', '.slidelink', function(e){ e.preventdefault(); var target = jq(this).attr("href"); $placehold.fadein(360).addclass('loading'); getdetails(target) .done( function(result) { renderdata(result); }) });
what doing wrong?
your problem seems lie in endresult.fadeto(0,0).appendto($placehold); method. appendto occur after fadeto complete, rest of method executed while fadeto has started. 'might' solve it:
var endresult = $(data).find('#productdetails'); endresult.fadeto(0,0, function() { $(this).appendto($placehold); $placehold.removeclass('loading'); $(this).fadeto(300,1); // <- added per request // console log uncalled data works fine // called again, 0 every single time console.log( jq('#anyelementinajaxdata').outerheight(false) ); });
Comments
Post a Comment