Skip to content
This repository has been archived by the owner on Jul 29, 2022. It is now read-only.

Added intercept function, which is useful for handling JSON responses. #66

Closed
wants to merge 1 commit into from

Conversation

randell
Copy link

@randell randell commented Jun 28, 2012

Useful when you want to post-process the returned json data before it hits the page.

For example, your server returns the following json string: { "status": 1, "result": "value to be displayed", "other": "some other data" }, and you would like to process the "status" and "other" fields, and display the "result" field in the jeditable input field.

In your own code, you can do something like the following:

$(some_field).editable(
 '/some_url_on_your_server',
 {
     indicator : "<img src='/images/spinner.gif'>",
     tooltip: "Click to edit.",
     indicator: "Saving...",
     onblur: "submit",
     intercept: function (jsondata) {
         obj = jQuery.parseJSON(jsondata);
         // do something with obj.status and obj.other
         return(obj.result);
     }
}

From: http://stackoverflow.com/a/4611865/106778

@NicolasCARPi
Copy link
Owner

Hello,

Thanks for your contribution. The code has been merged and a demo has been added on the demo page for it :)

Cheers,
~Nico

@josiahke
Copy link

tried this feature and it is not handling the json

@NicolasCARPi
Copy link
Owner

@josiahke Please open an issue with reproducible steps. See issue template.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants