Editor error handling api
Editor error handling api
Tropicalista
Posts: 6Questions: 0Answers: 0
Hi,
I need to create new record using editor api.
I create a form and use this to submit data:
[code]
editor.create( null, null, false );
editor.set( 'url', $('#myinput').val() );
editor.submit();
[/code]
This works great.
But I have set url field validation as url. If I try to submit a non-url string I get error: Uncaught TypeError: Cannot read property 'top' of null
Probably because there is no form to display with error. I don't know.
How can I solve this problem? I have client-side validation, but really server-side is best. So I need a way to display error message. It's possible?
What if I use
[code]
$(document).ready(function() {
var editor = new $.fn.Editor( {
"ajaxUrl": "php/index.php",
"domTable": "#example",
"ajax": function ( method, url, data, successCallback, errorCallback ) {
$.ajax( {
"type": method,
"url": url,
"data": data,
"dataType": "json",
"success": function (json) {
successCallback( json );
},
"error": function (xhr, error, thrown) {
errorCallback( xhr, error, thrown );
}
} );
}
} );
} );
[/code]
I could set an error handling function here? could someone give me help?
I need to create new record using editor api.
I create a form and use this to submit data:
[code]
editor.create( null, null, false );
editor.set( 'url', $('#myinput').val() );
editor.submit();
[/code]
This works great.
But I have set url field validation as url. If I try to submit a non-url string I get error: Uncaught TypeError: Cannot read property 'top' of null
Probably because there is no form to display with error. I don't know.
How can I solve this problem? I have client-side validation, but really server-side is best. So I need a way to display error message. It's possible?
What if I use
[code]
$(document).ready(function() {
var editor = new $.fn.Editor( {
"ajaxUrl": "php/index.php",
"domTable": "#example",
"ajax": function ( method, url, data, successCallback, errorCallback ) {
$.ajax( {
"type": method,
"url": url,
"data": data,
"dataType": "json",
"success": function (json) {
successCallback( json );
},
"error": function (xhr, error, thrown) {
errorCallback( xhr, error, thrown );
}
} );
}
} );
} );
[/code]
I could set an error handling function here? could someone give me help?
This discussion has been closed.
Replies
Allan
[code]
editor.create( null, null, false );
editor.set( 'url', 'ww.llo.li' );
editor.submit( function () {
alert( 'Form successfully submitted!' );
}, function () {
alert( 'Form encountered an error :-(' );
}
);
[/code]
but got same error.
The error occurs in line 49 of datatables.editor.js
[code]
0
I've just committed the fix and it will be packaged up into the next Editor release (likely 1.2.2). I'm not 100% certain on a timeframe for the release yet, there are a few other things to be finalised for it, but if it drags out at all, I'll package 1.2.2 with this change.
Regards,
Allan