I am implementing flot in a small jquery mobile framework site. The page / content div that contains the flot is on a secondary page. The first time the flot page is shown, the chart renders nicely. Moving back to the primary page and forward again to the flot page, the chart does not render.
The content is coming from an asp mvc view:
<div id="chartcontainer">
<div id="chartdiv" style="height:300px;width:400px;"></div>
</div>
<script type="text/javascript">
$(function () {
var d1 = [[1, 1], 开发者_StackOverflow社区[2, 2], [3, 3]];
$.plot($("#chartdiv"), [d1]);
});
</script>
You might need to refresh the page, try .page()
$.plot($("#chartdiv"), [d1]).page();
document ready is generally a thing that doesn't work as expected with jQuery Mobile.
instead of $(function(){})
try binding to a page*
event like this:
$('div#withMYgrid').live('pageshow',function(){
//plot here
});
精彩评论