Hey...
I am using AUI Restful Table in a Stash plugin. When the user submits invalid data I am returning a 400 status code as I believe is correct. I am binding to the event: AJS.RestfulTable.Events.VALIDATION_ERROR, and although my handler is being called, nothing seems to stop a big nasty dialog displaying the summary: 'Something went wrong while trying to serve your request. Try reloading the page.'.
This is coming from getDominantAJAXError in error. js - is there a way of just telling it that I will handle any non-OK status codes myself?
Community moderators have prevented the ability to post new answers.
Attempt two, still not actually tested.
(function() { var oldSync = Backbone.sync; Backbone.sync = function(method, model, options) { if (model instanceof AJS.RestfulTable.EntryModel) { options = AJS.$.extend({ statusCode : { 400 : false } }, options); } return oldSync.apply(this, method, model, options); }; })();
I have to special-case the EntryModel in the global sync method. This is ugly but should work (fingers crossed).
Thanks Adam - I abandoned restful table in the end, but this may come in useful somewhere else.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am having similar problems with restfultable and validation for a jira plugin,
maybe you can help me here a little thx: https://answers.atlassian.com/questions/283773/aui-restfultable-validation-errors-not-displayed
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jamie,
Restful Table and Stash don't play well together, currently. You should note that RestfulTable is experimental, so it may change unexpectedly.
We might offer a better alternative in the future, but for now if you want to use RestfulTable in Stash, you'll have to override the default model and use your own sync method. Here's one way you can do it:
var StashEntryModel = AJS.RestfulTable.EntryModel.extend({ sync : function(method, model, opts) { return Backbone.sync(method, model, AJS.$.extend({ statusCode : { 400 : false // ignore HTTP 400s. } }, opts)); } });
// Use our model instead of the default. new AJS.RestfulTable({ ... model : StashEntryModel });
I haven't tested it, but that snippet should create a new kind of model that tells our ajax transport to ignore HTTP 400s during sync.
If you want to just ignore _all_ errors (including being logged out, or server going down, or other catastrophic errors), you can use `* : false` in place of `400 : false`. But generally that error handling is pretty useful.
Let me know if you find issues with it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
overriding "save" works though... but I still can't avoid the big server error message :-(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Adam - thanks for your answer. It seems utterly plausible, but I'm falling at the very first hurdle. I can't even get my sync to run... the default EntryModel.sync is still being called. My code:
model: AJS.RestfulTable.EntryModel.extend({ sync : function(method, model, opts) { console.log("sync"); return Backbone.sync(method, model, AJS.$.extend({ statusCode : { 400 : false // ignore HTTP 400s. } }, opts)); } }),
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Big bounty in it for you if you have any other ideas!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Right, EntryModel's save method assumes you don't subclass it and references itself harcoded :/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
On the destroy function all the arguments are undefined so you can't see if there are validation errors.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.