0

I'm loading form into jquery-ui dialog using jquery.html() function and then Submitting doesn't work (alert doesnt show) - can someone tell me why?

here it is: http://jsfiddle.net/GMcev/11/

1
  • because it is type="submit", on clicking , it is submitting form Commented Jun 19, 2012 at 10:53

3 Answers 3

2

You need delegate event. Because your button is added to DOM after page load ie. dynamically, so you need something like following:

$('body').on('click', '.button', function() {
    alert('TEST!'); //it doesnt work            
});

DEMO

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

1 Comment

But you see, I'm loading some form into my ui dialog after click the link (after the dom is ready i think) and I want to submit it via ajax - will it work using one of yours methods?
2

Call

$(".button").click(function() {  
            alert('aaa');

in open action of dialog

$("#dialog").dialog({
        autoOpen: false,
        title: "contact",
        open: function() {
            $(".button").click(function() {
                alert('aaa');
            });
        }
    });

Comments

2

i suggest to put onclick in submit button

<input type='submit' name='submit' class='button' 
id='submit' value='Zapisz' onclick='dingDong()' />

http://jsfiddle.net/GexFz/1/

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.