Jump to:

5541 Posts in 1738 Topics by 1224 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Fire jquery after ajax load in admin panel [SOLVED]

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

Page: 1
Go to End
Author Topic: 331 Views
  • Jellygnite
    Avatar
    Community Member
    11 Posts

    Fire jquery after ajax load in admin panel [SOLVED] Link to this post

    Hi,

    I have been struggling with this for a while now.

    I have some dropdowns in the admin panel for a set of data objects that I want to change dynamically. They are for a car selection e.g. Make > Model > Year > Series.

    I can access the data for each dropdown using the live function like this:

    $( "select#Form_ItemEditForm_MakeID" ).live( "change", function() {
       alert( "This works!" );
    });

    But this only runs when the dropdown is changed. This will be useful when I want to change the other dropdowns but how can I can store the dropdown's options data using Jquery once the ajax load is complete? I can get it to work once if I do a hard refresh of the page but if I navigate using the admin panel tabs the page is loaded via ajax.

    Can anyone point me in the right direction?

    Thanks.

  • Jellygnite
    Avatar
    Community Member
    11 Posts

    Re: Fire jquery after ajax load in admin panel [SOLVED] Link to this post

    I found it. I just needed to use the onmatch selector.

       $('select#Form_ItemEditForm_MakeID').entwine({
          onmatch: function(e){
             console.log("This works");
          }
       });

    If you know of a better way I am happy to hear it.

    331 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.