June 18, 2012
Jquery – need help on usage
Question by Donald
Is this the right way of using the php script in the jquery function?
The pathToTabImage variable
<script type="text/javascript">
$(function(){
$('.slide-out-div').tabSlideOut({
tabHandle: '.handle', //class of the element that will become your tab
pathToTabImage: '<?php echo $this->baseurl ?>/templates/<?php echo $this->template; ?>/images/ack.jpg';, //path to the image for the tab //Optionally can be set using css
alert(pathToTabImage);
imageHeight: '122px', //height of tab image //Optionally can be set using css
imageWidth: '125px', //width of tab image //Optionally can be set using css
tabLocation: 'right', //side of screen where tab lives, top, right, bottom, or left
speed: 600, //speed of animation
action: 'click', //options: 'click' or 'hover', action to trigger animation
topPos: '600px', //position from the top/ use if tabLocation is left or right
leftPos: '550px', //position from left/ use if tabLocation is bottom or top
fixedPosition: false //options: true makes it stick(fixed position) on scroll
});
});
Answer by Starx
It is one of the available ways to inject PHP codes, inside as HTML, CSS, or JS Document/Snippet. However, syntactically, there are few errors.
PHP Error
<?php echo $this->baseurl ?>
No selicolon on the end statement
JavaScript Error
pathToTabImage: '...';, //...
Unneeded semicolon, ending a statement in an incorrect way
alert(pathToTabImage);
Injecting an independant statement inside another statement