Search

I recently downloaded and installed Symphony’s latest to my staging site and am really excited about how easy it’s been to write and customize for. Then I began working with my .animate functions in JQuery and have had nothing but issues trying to get the code to fire in the .xsl world, am I missing something?

Sample install can be found at: http://stage.freshma.de/ currently and you can tell it’s pretty much using the default template mostly at present. I want to push forward but cannot see putting too much time into it if I cannot have a simple JQuery document.ready to help affect pages and events.

I did search the forum and possibly wasn’t looking for the right combo as I found nothing that seemed to relate to my query directly. Any help or even direction to the right thread would be greatly appreciated all!

-Jack

I can’t see any extra JavaScript that you’ve added to the frontend beyond including the jQuery library and a cookie plugin. Surely just add another <script> element after these which points to your own JavaScript file (which includes the document ready event subscription.

Are you writing the javascript inline in the xsl file? I couldn’t see anything in the source of that example link you sent. Try a simple alert, it works in my templates ok:

    < script type="text/javascript">

    jQuery(document).ready(function () {
            alert('test')
    });             

< /script>

Try making sure that your including that call in your master.xsl utility so that its not depended on another template perhaps? or within the match=”/” template in your specific stylesheet.

I know if your JS has any xml type characters ( like < or > ) you need to wrap the inline JS in a CDATA tag. Example.

Of course if you javascript is in a seperate file ( where it probably belongs? ) then I’m not sure why its not working. Perhaps update your example with the javascript you want to use in it?

Hm, I can only see jQuery and jquery.cookie in you source. Are you sure you have your custom JS included in a script tag, either linked or inline?

Edit: Oi, I was a bit too slow.

Yeah, had to take it out of the page, when I had the full code in there before the page wouldn’t render any html, view source came up completely blank.

Added it back in and got the page but no rendered styles, this is my document.read stuff below.

    $("document").ready(function() {

    alert("we're working!");

    var animation = $.cookie('fresh_animation');
    //alert(animation);

    if ($.browser.msie && $.browser.version == "6.0")
        animation = 'false';

    if (animation != 'false') {
        $(".fresh").animate({ top: '0px' }, 1000, function() {
            $(".made").animate({ top: '0px' }, 1000, function() {
                $.cookie('fresh_animation', 'false');
            });
        });
    }
    else {
        $(".fresh").css({ top: '0px' });
        $(".made").css({ top: '0px' });

    }
});

You’re probably getting a PHP error, or an XSLT processing error. Try enabling visible PHP errors on your server by adding this to the .htaccess file:

php_value display_errors on

Added that, saw no errors. Wrapped the script inside CDATA with the page now coming up half the time styled the other half unstyled. And the alert at the top just to check if it’s firing, is not.

Also, thank you all for your prompt replies, I love to see a lively community!

This is because you’re getting a JavaScript error (check your browser console) because of this line:

if ($.browser.msie &amp;&amp; $.browser.version == "6.0")

XSLT does this, it will convert characters to entities. That is why, unless unavoidable, you should put your JavaScript into external .js files that you link to (like you link to the jQuery library).

@nickdunn Thank you so much! That did the trick.

It’s odd because I wrapped all of it into a separate .js file last night before posting and it didn’t work properly, odd caching issue perhaps.

Thanks all, Issue fixed!

Well, not sure if it’s truly solved, seems to load the css here and there but not always. Seems to only happen when firing off the javascript at the bottom of the page.

I’ll keep working at it but if anyone else had similar issues I’d love to hear.

I edited a textarea field called Codearea (available in the extensions section) that allows to store JS in Symphony for output in XSLT as I had the same problem.

I must admit though, I stopped using it in favour of external files… ;o)

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details