How to use jquery selector for json result

I am creating an inbox system for my website that provides basic communication between users. I get results using jquery calling a web service.

Then I use the jquery template engine to display the results on the screen. So far, everything is working well. but now I want to add some click functions to certain parts of messages in mailboxes. For example, I want the message heading to be clickable so that it expands / collapses the full text that is hidden in the div below it.

But I cannot use the jquery selector for this dynamic json result. It works when I put the function in the href tag itself, but I really don't want that. I also tried adding a function after the success function, but no luck. Is it even possible to use selectors with a template engine?

Hope I cleared up, otherwise feel free to ask for more information. Thanks a lot Regards, Mark

+4
source share
3 answers

Have you tried using jquery.live? http://api.jquery.com/live/

+3
source

Sorry, you will see that this happens all the time when something goes wrong, and I ask the question as soon as after that he decides for himself. Indeed, you can use the jquery selector for dynamic elements. Just make sure you put it after processing the template and into the ajax success function.

Thanks.

+1
source

Are you trying to select the json that is returned from the webservice, or are you trying to use the jquery selector to find the element added previously to the page?

0
source

All Articles