javascript - Formatting Elements After an Ajax Call -


i'm trying have ajax call apply formatting elements won't exist until complete. using success function in actual call isn't working. function called element ('.content-cell') isn't found, presumably because doesn't exist yet. majority of similar answers address event delegation not applying styles.

am approaching correctly? best method applying styling , handlers after ajax retrieval?

$("#calendar-panel").load("url", setupcal());   function setupcal(){     console.log("setupcal");     var cell_width = $('.weekday-cell').width();     if ($('.content-cell').length){         console.log("content cell exists");     } else {         console.log("content cell not exist");     }     $('.content-cell').css({height:cell_width}); 

the console output of code is: 'setupcal'; 'content cell not exist'.

i think issue might calling setupcal function in line executing load function. because have included parentheses execute function (and return it's results) opposed passing callback argument.

you can try referencing name of function in line so:

$("#calendar-panel").load("url", setupcal); 

if setupcal function called while load function being 'defined' element not exist yet , hence give output seeing: ""content cell not exist"".


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -