Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Customising the CMS /

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

Fire jquery after ajax load in admin panel [SOLVED]


Go to End


2 Posts   1522 Views

Avatar
Jellygnite

Community Member, 12 Posts

27 February 2014 at 2:18pm

Edited: 27/02/2014 4:47pm

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.

Avatar
Jellygnite

Community Member, 12 Posts

27 February 2014 at 4:47pm

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.