0

I have a heavily customized questionnaire with a list that is looking like that

<ul>  
    <li class="customCheckbox">
    <li class="customCheckbox">
</ul>

This questionnaire is loaded by a JQuery.ajax call and the js code that comes with it is correctly processed when displayed in a JQuery UI dialog. The customCheckbox present on the initial page are correctly processed by my (function($){ [...] }) in an external script jquery.customCheckbox.js

I need something like .live() but since it is removed from JQuery I can't go far with that. I don't want to reload the script in the AJAX call if possible. This question is about the same but me it is not only about an event listener. It modifies the checkbox adding a class and listeners and other stuff.

Actually I am looking for something that would call my (function($)... like $(document).ready.

Thanks

3
  • 1
    Maybe I missed it, but is there a question in there somewhere? Commented Mar 26, 2013 at 15:34
  • @JoelEtherton How can I reprocess JQuery over a dinamically created element which is not only an event listener that can be fixed with .on? Commented Mar 26, 2013 at 15:43
  • You've said it in 2 comments, but it doesn't have any meaning or context to me. reprocess jQuery -- what do you mean by this? Commented Mar 26, 2013 at 15:54

2 Answers 2

1

You can use jQuery.on(), it has replaced .live()

Sign up to request clarification or add additional context in comments.

6 Comments

I can't use .on since it is not simply an event listener. Actually it is more of a JQuery extension written by one of my partners. I know that .on would handle the events on dynamically created elements.
Johnride - from the jQuery docs description "Attach an event handler function for one or more events to the selected elements."
I know about .on I NEED to reprocess JQuery since it IS NOT only an event listener.
Why don't you just wrap all of your jQuery that you want bound in a function and call it after the ajax is loaded?
This is very close to what I need but I can't wrap it in a function since I can't edit the code. And I am pretty sure there is a way to call expressely all JQuery functions to run on the loading of a new element. I have seen evalScripts : true or something alike with another lib while searching.
|
0

Don't see the code here you are trying to modify or it is not clear what you are trying to accomplish. Based on what you said, have you tried using .delegate()?

$('#yourButtonIDContainer').delegate('#yourButtonID', 'click', functionCalled);

function functionCalled(e) { e.preventDefault(); *** Do Something Here **** }

Not sure if this helps, but let me know more details if not.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.