illiquent
illiquent

Reputation: 171

nyromodal ajax form/filter docs or COMPLETE examples?

I'm one of the hundreds of folks confused by nyroModal's lack of complete examples.

For such a feature rich plugin, it's difficult to find a single comprehensive example of most of the features.

I'm trying to open a form within a nyroModal window, and have the form send values to a page via Ajax, and then based on the response, close the window. I know this should be/is easy, but without an example or understandable documentation.

So far I have it opening in the window, and submitting in the window but ... no ajax. (Not even sure if nyroModal can handle it. Not sure if I use "filters", since there isn't an example of how you'd implement the listed filters.)

Here is what I have for the nyroModal call:

<script type="text/javascript">
    $('.nyroModal').nyroModal(
    {
// not sure if these are needed, but without an example, better start guessing!
callbacks: {
    afterClose: function(nm) {
        alert('Handled!');
    }
}
});
</script>

Here is my form that is called into the nyroModal window: note: making the form of class: nyroModal, makes the form submit within the modal. (would make a good example too)

<form name="this" method="post" class="nyroModal" action="/vendor/orderDetail.cfm">
    <cfoutput><input type="hidden" name="oid" value="#oid#"></cfoutput>
    <input type="text" name="comment"><input type="submit" value="Accept Product Request">
</form>

What I am wanting to do is When user submits the form, I want to send the data via AJAX to the "action" page. That would generate an JSON response, and depending on the response, then close the window. So, is this possible with nyroModal? After MUCH MUCH looking, I can't find a single reference to this functionality, except the "features", but its not shown how its done.

Can anyone point me to an example or some docs?

Certainly there's got to be an example somewhere illustrating how to use the features listed, namely filters/callbacks.

If anyone has some complete examples, it would save us all some time, and NyroDev can stop answering "bugs" that are actually just confused people wanting an understandable set of documentation.

Upvotes: 4

Views: 2414

Answers (1)

macgyver
macgyver

Reputation: 1279

I guess you are looking for open manually a form with nyroModal. My answer in Open iframe manually in nyroModal explains how to do.

So if you load a page with inside a form and using it without ajax, after clicking the submit button the page will be updated into the modal window (iframe). If you want to send the data via AJAX to the "action" page, generate a JSON response and update your modal page, close it... you have to use a code like this:

    $('input#submit').click(function(e){
        e.preventDefault();

        // business code

        if (formToClose)
            $.nmTop().close();
    });

Of course you can use also the callback afterClose if you need to manage something when the modal window is closed.

Upvotes: 0

Related Questions