1

I have a form within modal and I don't seem to be able to catch the submit event.

Let's say we have a html page defined as (for the sake of simplicity leaving out any templates defined by me)

<body>
    <button class="ui button">Open modal</button>
    <div class="ui small modal">
        <div class="header">
            Enter your email
        </div>
        <div class="content">
            <form class="ui form">
                <div class="field">
                    <div class="ui left icon input">
                        <i class="at icon"></i>
                        <input type="email" name="email" placeholder="Email">
                    </div>
                </div>
                <div class="ui error message">
                </div>
            </form>
        </div>
        <div class="actions">
            <div class="ui negative button">
                Cancel
            </div>
            <div class="ui positive primary loadable button">
                Reset password
            </div>
        </div>
    </div>
</body>

and registred template events

Template.body.events({
    'click button': function () {
        $('.modal').modal('show');
    },
    'submit form': function () {
        alert('called');
    }
});

When I submit the form it doesn't get cought by the handler. Why and what's the best approach?

I got something similar working by defining the inner content of modal as template, but it makes things much harder. Is there any other way?

EDIT: Here's meteorpad that demostrates the issue

pikausp
  • 1,142
  • 11
  • 31

1 Answers1

0

The reason behind this behavior is that modal is detached from the DOM. This behavior can be overriden by setting detachable: false

Here's working meteorpad

Credits

pikausp
  • 1,142
  • 11
  • 31