Build with IDX Broker › Forums › General Discussion › How to use JS on saved properties after ajax
Tagged: ajax, javascript, my account
-
AuthorPosts
-
-
I’m trying to make some changes on the “My Account” page using javascript to move some elements…for example moving the price above the image.
I’m having an issue with the “My Saved Properties” section. Clicking on “My Saved Properties” loads the properties via ajax and I’m having a tough time figuring out how to apply the js changes after the properties have loaded.
I’ve tried a lot of different functions to make the change after clicking on “My Saved Properties” and after the ajax has loaded the properties, with no luck.
I’m hoping someone can point me in the right direction…any help is really appreciated.
Happy Thanksgiving everyone 🙂
Attachments:
You must be logged in to view attached files.(+1 rating, 1 votes, rated)
You need to be a registered member to rate this post.Loading... -
SO loading after ajax can be done a few ways, you can set a timeout like:
setTimeout(function(){ //do some JS stuff }, 3000);
Or you can listen for an event. Like the appearance of an element. Example: http://stackoverflow.com/questions/6115026/how-to-tell-javascript-to-execute-a-function-after-an-element-has-been-loaded
function myFunc() {
if (document.getElementById('myElement')) {
// do stuff
} else {
setTimeout(myFunc, 15);
}
}(+1 rating, 1 votes, rated)
You need to be a registered member to rate this post.Loading... -
Thanks Antonio. Tried this (and a bunch of others) with no luck. I thought I had it but realized once I added more than one property, it was appending the price for all properties to each listing. So if I had 6 listings, each one showed all 6 prices.
I tried using a loop with the setTimeout function, but gave me an infinite loop.
I’ve been trying to work with some form of this:
$(".IDX-myAccountLink").click(function(){setTimeout(function() {
if (document.getElementsByClassName('IDX-savedProperty')) {
alert( 'Button Clicked' );
$(".IDX-savedPropListingPrice").appendTo(".IDX-savedPropertyInfo");
}
}, 1000);
});
Any other thoughts? Thanks again for taking a look.
(+1 rating, 1 votes, rated)
You need to be a registered member to rate this post.Loading... -
I ended up using CSS to manipulate the elements. Would still like to know how I can accomplish this if anyone has any thoughts, but had to find a working solution so I gave up on the JS version.
(+1 rating, 1 votes, rated)
You need to be a registered member to rate this post.Loading...
-
-
AuthorPosts
- You must be logged in to reply to this topic.