Hashibul hasan
Hashibul hasan

Reputation: 187

joomla plugin internal script code error

IN my joomla plugin I want to add internal script for animate css.but my code give error.

my code

$doc->addScriptDeclaration('
    jQuery(document).ready(function(){
        $('#canimation').addClass('animated "'. $this->_animation_c1.'"');  
    })  
');

Upvotes: 0

Views: 57

Answers (2)

Irfan
Irfan

Reputation: 7059

THere is an error due to quotes.Below code will work -

$doc->addScriptDeclaration('
    jQuery(document).ready(function(){
        $("#canimation").addClass("animated '. $this->_animation_c1.'");  
    })  
');

Upvotes: 1

Tom
Tom

Reputation: 188

A ; seems To be missing:

$doc->addScriptDeclaration('
    jQuery(document).ready(function(){
        $('#canimation').addClass('animated "'. $this->_animation_c1.'"');  
    });
');

And you are constructing your String wrong. The Apostrophe in Front of #canimation will end the First string.

Try to build the String in a var at first and Output this var To See if it is the right one.

$jsString = "*your js code*";
echo "<pre>" . print_r($jsString, true) . "</pre>";
$doc->addScriptDeclaration($jsString);

Upvotes: 0

Related Questions