editor submit function issue

editor submit function issue

tigeritstigerits Posts: 4Questions: 0Answers: 0
edited December 2012 in Editor
I am evaluating the editor, found the following issue:

I initiated a new editor, which do not have a Dom table, just want submit some value to server and process the server response. But the following code not works:

[code]
enveditor.create(
'Please specify how many environment this application needs', {
"label": "Next",
"className": "btn btn-primary",
"fn": function () { this.submit(
function(){
alert('success');
},function(){
alert("error!");
} ,null, false
); }
}, false
);
[/code]

the form was submitted to server and the server response is back, but the success call back not run, the are javascript error in the console:

TypeError: l.fnSettings(...) is null

Can anybody have a look what's wrong here,

Thanks

Tiger

Replies

  • allanallan Posts: 61,734Questions: 1Answers: 10,110 Site admin
    Are you able to link us to a test page please? I'm afraid it isn't immediately obvious from your code what is wrong as that looks like it it should be working okay there!

    The callbacks aren't executing due to the JS error, but I'm not sure what is causing the JS error.

    Allan
  • tigeritstigerits Posts: 4Questions: 0Answers: 0
    Hi Allan,

    For now I can not link you to the test page, but my idea is when click on a link in side table cell, popup a form which does not do the regular CRUD of the table data, but submit some values to the server, so I did not link the editor to a DOM table.

    I may datatable, there is a link named "Design" in the last column, we user click on that link, the system need get the id of the row, and use that id to call backend web server to get a list of selected environments, the popup a form to show all the selected environments, and let user change the selection and submit back to the server. This action does not add/edit any rows in the datatable, please check the following code:

    [code]
    $('#projectlist').on('click', 'a.editor_design', function (e) {
    e.preventDefault();
    var data=$(this).parents('tr')[0].getAttribute("id");
    var id=data.substr(data.indexOf("_")+1);
    loadEnvironments();
    loadEnvs(id);
    enveditor=new $.fn.dataTable.Editor( {
    "ajaxUrl": "${url}/projects/"+id+"/environments",
    "fields": [ {
    "label": "Environments:",
    "name": "environments",
    "dataProp": null,
    "type": "checkbox",
    "ipOpts": environments
    }
    ]
    } );
    enveditor.create(
    'Please specify how many environment this application needs', {
    "label": "Next",
    "className": "btn btn-primary",
    "fn": function () { this.submit(
    function(){
    alert('success');
    },function(){
    alert("error!");
    }
    ); }
    }, false
    );
    if(envstr!="")
    enveditor.set('environments',envstr);

    enveditor.open();
    });
    [/code]

    right now the either the success function or error function not running but got a javascript error I posted before in the console, can you let me know what caused the error?

    the server return is a test json text:

    {"id":-1}

    Could be the server return caused this problem, I guess the editor first set some data based on the server return but not successful, can I bypass this data setting?

    Thanks a lot, need your guidance.

    Tiger
  • allanallan Posts: 61,734Questions: 1Answers: 10,110 Site admin
    > so I did not link the editor to a DOM table.

    I might not quite be understanding this, but are you saying you are using Editor without a DataTable? I'm afraid I doubt that is possible at the moment. It might be something we look at adding to Editor in future, but just now it is very tightly integrated with DataTables and it absolutely must have a DataTable backing it, since it makes a number of API calls to DataTables.

    Allan
This discussion has been closed.