Jump to:

23454 Posts in 18904 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » [solved] jQuery(document).ready(function() not working in admin

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 19716 Views
  • Martijn
    Avatar
    Community Member
    271 Posts

    [solved] jQuery(document).ready(function() not working in admin Link to this post

    I try to get jquery to work in the admin of the cms, but it does not recognize page elements like input.text or #Form_EditForm_Title.

    I forced an alert with

    jQuery(document).ready(function(){
    alert('test');
    });
    Wich popups before the SS loadingscreen is gone.

    But what i think is dat the RightAdminside is loaded after the complete page is loaded?

    Is there a way to load all the pageelements before the complete page is rendered?

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: [solved] jQuery(document).ready(function() not working in admin Link to this post

    Make sure when you write your file you wrap your jquery in a function($) to stop conflicts. http://doc.silverstripe.com/doku.php?id=jquery#guidelines. $(document).ready() should mean that the form fields exist so you shouldn't have any issues. For an example of using jquery in the cms look at the model admin JS code. This was the first part of SS written in jquery so provides the main reference.

  • Martijn
    Avatar
    Community Member
    271 Posts

    Re: [solved] jQuery(document).ready(function() not working in admin Link to this post

    Thanks its working now!

    I didnt got the extra wrapper arround my code:

    (function($) {

    })(jQuery);

    Thanks!

  • merrick_sd
    Avatar
    Community Member
    95 Posts

    Re: [solved] jQuery(document).ready(function() not working in admin Link to this post

    I have some jQuery in the CMS Admin which matches field content to the Title field

    I have my jQuery working,

    Problem is, if I click on a page in the Left Hand side bar of the Admin to edit a different page, which obviously reloads the form as normal
    yet now my Jquery doesn't work on this form.

    If I refresh/reload the whole page it works again (its a pain having to refresh the whole page everytime

    anybody come across this kinda thing?

    Attached Files
    19716 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.