Standalone Edit doesn't fill the document and won't update

Standalone Edit doesn't fill the document and won't update

wannbergwannberg Posts: 11Questions: 3Answers: 0
edited September 2014 in Free community support

I am trying to use the stand alone editor and it doesn't seem to work correctly. I have the data-editor-field located in the html and then I call the script to initiate a new editor. But it doesn't update the html data. If I place data in the fields and click on the edit button, it populates the edit dialog, but won't save because it has no row id.

I have tried both on document ready, as well as my typical load js file and call the function DetailsTable. I know the file is loading and it is initializing. It just isn't updating the html.

I have also checked and it never accesses the php script during initialization. It does when I submit the update though. Am I doing something wrong or is the standalone editing not working?

                    <div class='row'>
                        <label class='control-label col-xs-6'>Type:</label>
                        <div class='col-xs-6' ><a data-editor-field="useCode"></a></div>
                    </div>

function DetailsTable(){ var editor = new $.fn.DataTable.Editor( { ajax: "datatables/tables/php/table.details.php", fields: [ { label: "Code", name: "useCode", type: "text" } ] } ); // Edit record $('#edit').on('click', function () { editor .title( 'Edit' ) .buttons( { "label": "Update", "fn": function () { this.submit() } } ) .edit(); } ); }

Answers

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin

    Hi,

    won't save because it has no row id.

    You need to tell it what the id is by passing in the id as the first parameter to the edit() method - for example you might have .edit( 12 ) if generated from a script or it could be read from a variable or DOM element. But in standalone editing Editor can't read an id automatically like it does from a table row.

    I have also checked and it never accesses the php script during initialization. It does when I submit the update though. Am I doing something wrong or is the standalone editing not working?

    What are you expecting it to do on load? Are you looking for it to populate the existing database value? It doesn't actually do that at the moment (good point - it possibly should!). At the moment it will take the value from the HTML - with the expectation that the value has been populated in the HTML for the user to see, but whatever templating you are using.

    Regards,
    Allan

  • wannbergwannberg Posts: 11Questions: 3Answers: 0

    Perfect, I can do that.

This discussion has been closed.