Change from using JS script to utilize JFactory::getDocument - Joomla! Forum - community, help and support
i have js code imbeded on page via extension sourcerer. working fine. change current utilize jfactory::getdocument()->addscriptdeclaration. input on hosw modify code ?
i have tried replacing not work
code: select all
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jquery demo</title>
</head>
<body>
<a href="http://jquery.com/">jquery</a>
<script src="media/jui/js/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("a").click(function(event){
alert("as can see, link no longer took jquery.com");
event.preventdefault();
});
});
</script>
</body>
</html>i have tried replacing not work
code: select all
<body>
jfactory::getdocument()->addscriptdeclaration('
(function($) {
$(document).ready(function(){
$("a").click(function(event){
alert("as can see, link no longer took jquery.com");
event.preventdefault();
});
}) (jquery);
');
</body>
you have forgotten switch html mode php.
<?php starts , end ?>
<?php starts , end ?>
Comments
Post a Comment