Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding a div with data()
    primarykey
    data
    text
    <p>I am generating a list of flash SWFs, the information comes from an ajax call which returns a json object which i loop through to create the rows of data using my makeAppRow function.</p> <pre><code>makeAppRow = function(myData){ var myStr = '&lt;div class="fileEntry"&gt;' myStr = myStr +'&lt;div class="appDate"&gt;'+dateFormat(myData.date_swf, "dS mmmm, yyyy, h:MM TT")+'&lt;/div&gt;' myStr = myStr +'&lt;div class="appName"&gt;'+myData.name_swf+'&lt;/div&gt;' myStr = myStr +'&lt;div class="appOptions" data&gt;' myStr = myStr +'&lt;div class="gotoAppBtn" data-options="'+myData+'"&gt;Open App&lt;/div&gt;' myStr = myStr +'&lt;/div&gt;' myStr = myStr +'&lt;/div&gt;' $('#appData').append(myStr); } </code></pre> <p>I need the json data to be attached to the <code>gotoAppBtn</code> so that when its clicked I can read in the data from the attached json object and use it in my click function, as you can see I've been trying to embed the data using the html5 data but I can't get it to work.</p> <pre><code> &lt;div class="gotoAppBtn" data-options="'+myData+'"&gt;Open App&lt;/div&gt; </code></pre> <p>I have a function so that when the button is clicked it loads in an swf.</p> <pre><code>$('.gotoAppBtn').live('click', function(){ //alert('button clicked') var myData = $(this).data("options") alert('../userfiles/'+myData.id_ugp+'/'+myData.id_swf+'/'+myData.launchfile_swf+'') console.log(myData); var flashvars = {}; var params = {}; params.menu = "false"; params.quality = "best"; params.scale = "noscale"; var attributes = {}; attributes.id = "flashAppDisplay"; attributes.name = "flashAppDisplay"; swfobject.embedSWF( '../userfiles/'+myData.id_ugp+'/'+myData.id_swf+'/'+myData.launchfile_swf+'', 'flashAppDisplay', myData.width_swf, myData.height_swf, myData.version_swf ,"../FAVideo/expressInstall.swf", flashvars, params, attributes) }); </code></pre> <p>but the data does not seem to be there, any pointers on where I am going wrong, or a better way to achieve this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload