Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Re-run script on ajax loaded content
    primarykey
    data
    text
    <p>I am using the <strong><a href="http://wordpress.org/plugins/advanced-ajax-page-loader/" rel="nofollow">Advanced Ajax Page Loader</a></strong> plugin for wordpress to load content via ajax, and I am having an issue with my custom jquery scripts not running on content when they are loaded via ajax. The scripts run fine if I load said pages directly from their url, but navigating to them via ajax loads causes them to not work.</p> <p>an example script I am using is</p> <pre><code>var o = { init: function(){ this.diagram(); }, random: function(l, u){ return Math.floor((Math.random()*(u-l+1))+l); }, diagram: function(){ var r = Raphael('diagram', 600, 600), rad = 73, defaultText = 'Skills', speed = 250; r.circle(300, 300, 85).attr({ stroke: 'none', fill: 'rgba(0,0,0,.10)' }); var title = r.text(300, 300, defaultText).attr({ font: '14px ralewaylight', fill: '#fff' }).toFront(); r.customAttributes.arc = function(value, color, rad){ var v = 3.6*value, alpha = v == 360 ? 359.99 : v, random = o.random(91, 100), a = (random-alpha) * Math.PI/180, b = random * Math.PI/180, sx = 300 + rad * Math.cos(b), sy = 300 - rad * Math.sin(b), x = 300 + rad * Math.cos(a), y = 300 - rad * Math.sin(a), path = [['M', sx, sy], ['A', rad, rad, 0, +(alpha &gt; 180), 1, x, y]]; return { path: path, stroke: color } } jQuery('.get').find('.arc').each(function(i){ var t = jQuery(this), color = t.find('.color').val(), value = t.find('.percent').val(), text = t.find('.text').text(); rad += 30; var z = r.path().attr({ arc: [value, color, rad], 'stroke-width': 20 }); z.mouseover(function(){ this.animate({ 'stroke-width': 30, opacity: 1 }, 1000, 'elastic'); if(Raphael.type != 'VML') //solves IE problem this.toFront(); title.stop().animate({ opacity: 0 }, speed, '&gt;', function(){ this.attr({ text: text + '\n' + value + '%' }).animate({ opacity: 1 }, speed, '&lt;'); }); }).mouseout(function(){ this.stop().animate({ 'stroke-width': 20, opacity: 1 }, speed*4, 'elastic'); title.stop().animate({ opacity: 0 }, speed, '&gt;', function(){ title.attr({ text: defaultText }).animate({ opacity: 1 }, speed, '&lt;'); }); }); }); } } jQuery(function(){ o.init(); }); </code></pre> <p>I understand you can use <strong>.delegate</strong> for click functions, but this does not help with non-click functions.</p> <p>Side note: the plugin comes with a "reload code" feature, and any script I paste in appears as reloaded in the console but doesn't actually function.</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.
    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