Joss Posted January 24, 2013 Share Posted January 24, 2013 I am having trouble modifying elements on the page list in administration. I am trying to do this: $('.PageListActions').addClass('test'); (Actually, I am trying something more complicated - but this is a simplified example just to work out the problem) The problem is that it is simply not taking at all. I have used similar bits all over an admin theme, but when it comes to the page list, it all falls over - or rather, does nothing at all. I have tried both $(document).ready(function() { and $(window).load(function() { and stuck it all over the place, but to no avail. I am assuming it is something to do with how the list is loading, but I dont know what to do about it. If I work my way backwards, I can addclass to PageListRoot, but not to PageList, which comes after the loading span. Anyone got any suggestions? Link to comment Share on other sites More sharing options...
Wanze Posted January 24, 2013 Share Posted January 24, 2013 Hi Joss, This happens because all the Pages are loaded via ajax. Your Code does not work for content that is loaded dynamically into the DOM. JQuery provides a function to select also ajax content: http://api.jquery.com/on/ Now the question: On which event do you want to append this class? Would work like this: $(document).on(events, selector, data, handler); Maybe you need to hack the ProcessPageList.js? Cheers Link to comment Share on other sites More sharing options...
Joss Posted January 24, 2013 Author Share Posted January 24, 2013 Hi Wanze Because this is a theme, I cannot hack anything but need to override instead. Basically I need to wrap the page list actions in some html and css to make it work differently. Link to comment Share on other sites More sharing options...
diogo Posted January 24, 2013 Share Posted January 24, 2013 That event would be .ajaxComplete(). Joss, try this: $(document).ajaxComplete(function() { $('.PageListActions').addClass('test'); }); 1 Link to comment Share on other sites More sharing options...
Joss Posted January 24, 2013 Author Share Posted January 24, 2013 Thanks Diogo! That worked. I will now try the series of bits I need to get the effect (this may horribly wrong.....) Joss Link to comment Share on other sites More sharing options...
Joss Posted January 24, 2013 Author Share Posted January 24, 2013 Okay, that sort of worked. I got all the required mark up in, but it messed up the way the actual page list worked. Everytime you clicked on a child page, it just added more and more buttons till I had a page of them. Oh well. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now