Adding behaviour to dynamically-added element... GAH...
Hey y'all.
I've got a series of pages which are based on a flowplayer tabs(div.panes > div) structure, whereby each tab is associated with a div which becomes visible onclick of the tab.
The divs themselves are populated by a series of load() statements - because each div is driven by a PHP file that accepts a GET/POST variable as its input.
At present everything is working perfectly, but I want to change something and can't figure out how to do so.
One of the tabs (the Summary tab) contains a flash SWF, and I want to replace the SWF with a <div> into which a
jqplot chart will render (jqplot is lighter weight and executes faster).
The problem is this: since the HTML of the div is created on-the-fly, I can't see how to instantiate jqplot (there's no 'click' event that can be used to drive a live() deelie).
I am absolutely certain that this can be done, but having wrestled with this for six hours I have had no success, and teh.Google didn't throw up any useful help.
An example of the page on which I want to replace the chart:
http://www.marketmentat.com/category/stocks/stock-workbench/?ASXCode=WYL
An example of the jqplot code that I want to put in where the SWF is on the former page:
http://www.marketmentat.com/WIP/jqPlot_Test.php.
Here's my thinking thus far:
(1) there's an empty div #chart1 (set to display:none while I'm trying to get this thing to work);
(2) there's a jqplot statement in the javascript in the footer, targeting #chart1 (although jqplot doesn't take the hash for id's). The statement works perfectly in the standalone page (jqplot_Test.php - see link above)
When the page loads, the chart data is fetched and returned as a JSON object, and its passed into the javascript block... but javascript returns an error saying that there was no plot target specified.
It clearly has something to do with the fact that #chart1 is inside a dynamically-created element. On another pane I use live('click', function(){}) to populate a dynamically-added div, and it works perfectly... however live() requires a one of a specific set of events.
I don't really want to add a button ('click me') to give me the click I need to use with live() load the chart.
Anybody got any hints?
Thanks in advance,
GT