By kelvinc on
I need to use jquery cycle plugin for my site.
And the following code works fine.
jquery_plugin_add('cycle');
drupal_add_js(' $(document).ready(function() {
$("#myslides").cycle("fade");
});','inline'
);
However, when I try to put some parameters to override the original one, I got problems. Is there any syntax error or I cannot override parameters in cycle.min ?
Here is the problematic code:
jquery_plugin_add('cycle');
drupal_add_js(' $(document).ready(function(){
$('#myslides').cycle({
fx: 'scrollDown',
speed: 300,
timeout: 2000
});
});','inline'
);
Comments
What sort of problems are you
What sort of problems are you having?
Your javascript string should
Your javascript string should be enclosed with a different character than the actual content (or escape the single quotes).
To keep the code easier to read and maintain, the string of javascript could be set in a variable and then referenced in drupal_add_js like:
For particularly gruesome
For particularly gruesome JavaScript PHP Heredoc can help:
nice heredoc Thank you for
nice heredoc
Thank you for your help