My favorites | Sign in
Project Home Downloads Issues
READ-ONLY: This project has been archived. For more information see this post.
Search
for
  Advanced search   Search tips   Subscriptions
Issue 404: I've added support for JSON based AJAX requests :)
2 people starred this issue and may be notified of changes. Back to list
Status:  Accepted
Owner:  ----


 
Reported by cal.leem...@googlemail.com, Jan 5, 2010
Hey all,

I've modified the NyroModal to correctly handle JSON Response queries, and
pass it to an object. I've also fixed a bug where the handleError function
was being overridden in the jQuery AJAX instance, due to an extend().

You will need to change debug to false if u want to hide debug.

	$.fn.nyroModal.settings = {
		debug: true, // Show the debug in the background

It will correctly process the text as JSON, and use the normal error
handlers if it was unable to process it. I.e. it will use contentError and
wrapper etc etc.

Obviously - these changes are very hacky, and I wouldn't recommend putting
them in the main branch, but it's there for anyone that needs it.

Enjoy! 

Here is an example of how to use it:

    function deleteUserFromResellerConfirm() {
        // Grab the default nyro settings
        settings = $.fn.nyroModal.settings
        
        // Now modify some of the settings
        settings['modal']=true
        settings['url']='/api/deleteUserFromReseller';
        settings['ajax'] = {
            dataType    :   'json',
            type        :   'post',
            data        :   {
                reseller_id :   reseller_id,
                user_id     :   user_id
            }
        }

        settings['afterJsonSuccess'] = function(data) {
            // Okay - display the success message
            $.nyroModalRemove()

            // Lol
            alert(data)
            
            // Execute callback
            callback()
        }

        // Load the modal
        $.nyroModalManual(settings);
    }
jquery.nyroModal-1.5.5.pack.js
53.2 KB   View   Download
Jan 5, 2010
#1 cal.leem...@googlemail.com
Hi,

Please find an amended version of the above.

This one works far better :)

Cal

New Example Usage:
    function deleteUserFromResellerConfirm() {
        // Grab the default nyro settings
        settings = $.fn.nyroModal.settings
        
        // Now modify some of the settings
        settings['modal']=true
        settings['url']='/api/deleteUserFromReseller';
        settings['ajax'] = {
            dataType    :   'json',
            type        :   'post',
            data        :   {
                reseller_id :   reseller_id,
                user_id     :   user_id
            }
        }

        settings['afterJsonSuccess'] = function(data) {
            // Check what the result was
            if (data.result=='ok') {
                // Execute callback (global to the scope)
                callback();

                // Fill
                return $("#deleteUserFromResellerSuccess").html()
            }
            else {
                return false
            }
        }

        // Load the modal
        $.nyroModalManual(settings);
    }
jquery.nyroModal-1.5.5.pack.js
52.7 KB   View   Download
Jan 5, 2010
#2 cal.leem...@googlemail.com
Sorry - last revision... Added support for HTTP 500 requests too :)
handleError needed changing to handleNyroError - otherwise it overwrote the one in 
jQuery. Quick hack ^_^
jquery.nyroModal-1.5.5.pack.js
52.7 KB   View   Download
Apr 16, 2010
Project Member #3 nyro...@gmail.com
I'm currently thinking of a version 2 of nyroModal and i'll review your code to
integrate it in there.
Thanks for charing
Status: Accepted
Labels: Type-Patch

Powered by Google Project Hosting