I have some code that i can insert into my Joomla 3.0 page that will call the java correctly. I am trying to switch to use the JFactory::getDocument for my java functions since it is native to Joomla.
Here is the working code
<!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 you can see, the link no longer took you to jquery.com");
event.preventDefault();
});
});
</script>
</body>
</html>
here is what i have tried that is not working
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery demo</title>
</head>
<body>
<?php
JFactory::getDocument()->addScriptDeclaration('
(function($) {
$(document).ready(function(){
$("a").click(function(event){
alert("As you can see, the link no longer took you to jquery.com");
event.preventDefault();
});
});
}) (jQuery);
');?>
</body>
</html>
Any assistance with this possible ?
Try using the following:
Hope this helps