Jump to:

3439 Posts in 1028 Topics by 869 members

Template Questions

SilverStripe Forums » Template Questions » [ Javascripts ] Conflic with admin section

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1283 Views
  • astate
    Avatar
    Community Member
    35 Posts

    [ Javascripts ] Conflic with admin section Link to this post

    When i login on admin section of silverstripe, the javascripts don't work on website.

    I htink the problem are because i use jquery and jquery-ui on my website.

    Sorry my english are not very good.

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: [ Javascripts ] Conflic with admin section Link to this post

    Usually the CMS won't include any of your front end javascript. That is why have to explicitly load your javascript in the CMS.

    Can you look at your web browsers error console and find the actual error. You may also what to try visiting the url - admin?flush=1&isDev=1 and try logging in. The flush is to refresh the cache, the isDev is used to disable the live mode JS minification.

  • astate
    Avatar
    Community Member
    35 Posts

    Re: [ Javascripts ] Conflic with admin section Link to this post

    The problem are when i am on Published Site and $SilverStripeNavigator are active. My jquery dont work on the Published Site

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: [ Javascripts ] Conflic with admin section Link to this post

    Ensure you javascript is in a closure - http://doc.silverstripe.org/sapphire/en/topics/javascript#custom-jquery-code

    Also include the built in sapphire jQuery rather than your own to avoid duplications.

  • astate
    Avatar
    Community Member
    35 Posts

    Re: [ Javascripts ] Conflic with admin section Link to this post

    i have my own jquery but i have already modify mod code.

    <script type="text/javascript">//<![CDATA[
       (function($) {
          $( "#accordion" ).accordion({
           header: "h3",
           active: false,
           collapsible: true,
             autoHeight: false,
             navigation: true
          });
       })(jQuery);

       $('.ppt li:gt(0)').hide();
    $('.ppt li:last').addClass('last');
    var cur = $('.ppt li:first');

    function animate() {
       cur.fadeOut( 2000 );
       if ( cur.attr('class') == 'last' )
          cur = $('.ppt li:first');
       else
          cur = cur.next();
       cur.fadeIn( 2000 );
    }
    (function($) {
       setInterval( "animate()", 6000 );
    } )(jQuery);      
    //]]></script>

    $SilverStripeNavigator

    </body>
    </html>

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: [ Javascripts ] Conflic with admin section Link to this post

    All your code should be inside the 1 closure.

    $('.ppt li:gt(0)').hide(); etc isn't in it.

    1283 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.