0

I am trying to execute a function right after i append a HTML element i've try a lot of things and nothing works, here is the source

$(doc).find("#"+parent.substring(1)).append(childStr)
$('[load]').each(function() {
    $(this).load(function(){
        loadmdl($(this).attr('id'));
    })
});

I know here are a lot of question similars but the answers of that questions doesn't help me. I really need an advice. Thanks!

5
  • I'm pretty sure your selector is wrong. 'load' is not really a valid html attribute. Commented Oct 17, 2011 at 4:27
  • Is not? Ok, but still i just used the attribute to collect the function that i going to execute after append the element but always execute the function before append the element. Commented Oct 17, 2011 at 4:35
  • It shouldn't. Try a .load class and iterating through that. Check if if your selector returns any elements at all, too. Commented Oct 17, 2011 at 4:40
  • Yes, return because the function collects correctly the strings that i going to execute. Commented Oct 17, 2011 at 4:41
  • I' ve change the name the attribute to 'loadafter', and still it's making the same thing executes the code before append the element. Commented Oct 17, 2011 at 4:44

1 Answer 1

2

Are you sure it's not working in the way you think it's not working? Calling additional JavaScript code after an .append is perfectly normal.

Are you sure the $('[load]') selector is returning what you want it to?

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

1 Comment

Yes i am sure because after that the function collect all the source attributes and execute the eval function with them as an arguments but always execute the function before append the element not after.

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.