I have purchased Editor but I can't integrate it with Laravel, can I do that by Backbone?
I have purchased Editor but I can't integrate it with Laravel, can I do that by Backbone?
hanyelbana
Posts: 24Questions: 0Answers: 0
I have purchased Editor but I can't integrate it with Laravel, can I do that by Backbone or any another method?
Thanks
Thanks
This discussion has been closed.
Replies
Thanks for purchasing Editor - I hope you get a lot of great use out of it.
It is possible to integrate Editor with Laravel, as the server communication that Editor performs is fully documented here: http://editor.datatables.net/server/ . You'd obviously need to write a little custom code that will interface with the Editor communication requirements if you aren't using the provided libraries. I'm afraid I don't have a Laravel integration example at this time.
> Backbone
Generally speaking, Backbone.JS will not work with DataTables - although it might be possible with the changes made in v1.10. I've done some work on Knockout.JS observables, integrating them with v1.10, but not Backbone. The same principle will likely apply though ( http://datatables.net/dev/knockout/ ).
I should say that Backbone and DataTables overlap in some areas, so any integration between them will always have some cost (usual in loosing features of one of the libraries).
Regards,
Allan
Then I have 2 options,
1- integrate with Laravel4 by send JSON to Editor and receive JSON from Laravel4.
When I start doing that : first: Laravel4 return JSON text like [ { "name" : "allan" } ]
and Editor doesn't read that. How can I change JSON text to make Editor accept it?
Second: How and where Editor send JSON to server and how to interact with it?
If there any near example from laravel as any mvc like Codeigniter or Rials it will be great.
2- For Knockout, is Editor example is ready? Could you send it to my?
Is there new version of Editor with Datatable v1.10, and where can I get v1.10.
Very Thanks
Hany
1. You can use the sAjaxDataProp option in DataTables to use plain arrays as the data source. Simply set sAjaxDataProp to be an empty string and point the sAjaxSource option at the script that provides the JSON.
Second: You can use the onPreSubmit event ( http://editor.datatables.net/api/#onPreSubmit ) to modify the data that Editor sends - although to be honest, it would probably be easier to change the server-side scripts.
2. v1.10 of DataTables is pre-beta at this time. It is not ready for general use (although very nearly!). There is no documentation written for it yet, something I am working on. 1.10 is available in git: https://github.com/DataTables/DataTables/tree/1_10_wip .
There is no Editor example of Knockout at this time, just DataTables.
Allan
1. first -> working -> very Thanks.
in Second: I will use REST, How can I catch JSON which sent from client after add, edit or delete actions?
Is there example for that or some explanation ?
Is REST the pest method for that with Laravel4?
Thanks,
Hany
Regards,
Allan
Thanks
Having said that, you can modify the data that is being send by using the onPreSubmit event that I mentioned: http://editor.datatables.net/api/#onPreSubmit . You need to manually modify the data to the structure you want.
Allan
Is there any example for using onPreSubmit?
Or what I should do in server side?
Laravel 4 server side act good with backbone like this code:
public function update($id)
{
$input = Input::json()->all();
$country = Country::find($id);
$country->name = $input->name;
$country->save();
}
But when I try to use ut with Editor I get this error:
message":"Trying to get property of non-object" with this line : $country->name = $input->name;
Thanks
I have changed the code to:
$input = Input::get('data');
$country = Country::find($id);
$country->name = $input['name'];
and it works now but I get this error:
Uncaught TypeError: Cannot read property 'error' of null dataTables.editor.js:2791
(anonymous function) dataTables.editor.js:2791
$.ajax.success dataTables.editor.js:3138
k jquery.js:2
l.fireWith jquery.js:2
y jquery.js:2
d jquery.js:2
Thanks