0

I can't figure out why I'm getting this error. I have read all documentation provided by the developer.

I placed this code in the Layout Update XML window:

<default>
<reference name="head">
    <block type="core/text" name="your.block.name">
       <action method="setText">
          <text><![CDATA[<script type="text/javascript">
    $(window).load(function(){
        $('.HoverAlls_Caption').HoverAlls({
            "coords":"0,100||0,75||0,100",
            "text_coords":"0,50||0,5||0,50",
            "speed" : "220,220",
            "text_speed" : "400,200",
            "opacity" : "0,1",
            "link_control" : "false,_blank",
            "bg_class" : "captionBackground",
            "text_class" : "captionText"
        });
    });
</script>]]></text>
       </action>
    </block>
    </reference>
</default>

Here is the site I'm trying to work on: http://staged.tailwatersflyfishing.com

Username: admin Password: admin

Thank you in advance! :)

  • I can't not see the error in header also see that your code in not added in site – Keyul Shah Nov 5 '14 at 15:50
1

I'm guessing above code is jQuery. In that case you'll need to wrap the code to prevent issues with the Magento Prototype library

<default>
<reference name="head">
    <block type="core/text" name="your.block.name">
       <action method="setText">
          <text><![CDATA[<script type="text/javascript">
    jQuery.noConflict(); // prevent conflicts with prototype

    (function($){ // and wrap it
    $(window).load(function(){
        $('.HoverAlls_Caption').HoverAlls({
            "coords":"0,100||0,75||0,100",
            "text_coords":"0,50||0,5||0,50",
            "speed" : "220,220",
            "text_speed" : "400,200",
            "opacity" : "0,1",
            "link_control" : "false,_blank",
            "bg_class" : "captionBackground",
            "text_class" : "captionText"
        });
    });
    })(jQuery);
</script>]]></text>
       </action>
    </block>
    </reference>
</default>
  • I'm still getting the same error. Placing this into the Layout Update XML is not resulting in the code being in the <head>. Could this be the issue? – Matt Jones Nov 5 '14 at 15:59
  • Not sure why it's not showing up in the head. Maybe you've misplaced it in the local.xml? – Sander Mangel Nov 6 '14 at 7:39
0

Try add this directly after add jquery library

...
<script type="text/javascript">
$.noConflict();
jQuery( window ).load(function( $ ) {
  // Code that uses jQuery's $ can follow here.
  $('.HoverAlls_Caption').HoverAlls({
     ....
  })
});
// Code that uses other library's $ can follow here.
</script>
...

See jQuery.noConflict()

0

I'm guessing you're placing this in local.xml within your current package/theme. I would suggest placing this snippet at the bottom of the page by targeting the "before_body_end" block. (you probably need to wait for DOM ready anyways).

<layout>
  <default>
    <reference name="before_body_end">
        <block type="core/text" name="footer.js.hoveralls">
            <action method="setText">
                <text>
                  <![CDATA[<script type="text/javascript">

$('.HoverAlls_Caption').HoverAlls({
        "coords":"0,100||0,75||0,100",
        "text_coords":"0,50||0,5||0,50",
        "speed" : "220,220",
        "text_speed" : "400,200",
        "opacity" : "0,1",
        "link_control" : "false,_blank",
        "bg_class" : "captionBackground",
        "text_class" : "captionText"
    });
                  </script>]]>
                </text>
            </action>
        </block>
    </reference>
  <default>
</layout>

Make sure you clear the layout cache as well.

  • If I'm understanding correctly.. I put this into the Layout Update XML and received an invalid XML error. Where did you intend for this to be placed "at the bottom of the page"? – Matt Jones Nov 5 '14 at 16:47
  • @MattJones, it sounds like you're placing this through the admin, via "Layout Update XML" for a CMS Page. If that's the case then remove <layout> and <default> opening and closing tags. – beeplogic Nov 5 '14 at 17:51
  • Ok - I've tried this as well and still seeing the error in the console... – Matt Jones Nov 5 '14 at 19:18
0

Ok - this is what did the trick...

I added this to the local.xml file within the open

<block type="core/text" name="your.block.name">
           <action method="setText">
              <text><![CDATA[<script type="text/javascript">
        jQuery.noConflict(); // prevent conflicts with prototype

        (function($){ // and wrap it
        $(window).load(function(){
            $('.HoverAlls_Caption').HoverAlls({
                "coords":"0,100||0,75||0,100",
                "text_coords":"0,50||0,5||0,50",
                "speed" : "220,220",
                "text_speed" : "400,200",
                "opacity" : "0,1",
                "link_control" : "false,_blank",
                "bg_class" : "captionBackground",
                "text_class" : "captionText"
            });
        });
        })(jQuery);
    </script>]]></text>
           </action>
        </block>

This block was placed within the reference tag that was already opened in the file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.