I'm trying to use the flot plugin for jquery and it keeps on complaining that a div has a width/height of zero. I'm actually including the javascript for this in a Django template. So my template file looks like:
<style>
#graph {
width: 100px;
height: 100px;
}
</style>
<script>
$.plot(stuff)
console.log($(#graph).width())
</script>
<div id="#graph">
</div>
This template code is inserted into the DOM of another page with AJAX.
$.ajax({
url: 'something',
success: function(data){ $("#content").html(data);
console.log($("#graph").width()) }
});
For some reason, I can't get the width to be non-zero, but if I test the width in the "success" function from the ajax call, it returns correctly. Is something wrong with the order that commands are being run/placed into the DOM?