Editor standalone and Upload // Issue with update process

Editor standalone and Upload // Issue with update process

fabioberettafabioberetta Posts: 74Questions: 23Answers: 4

Good morning,

I am using a standalong inline editor to change the user account information that includes a logo file.

To change the logo I am using Editor Upload function.

  • To render the data I am using an ajac call and the success call back function renders the fields including the logo. Works fine.
  • To inline edit I am using an editor that uses an ajax call to edit the data. I have a display function that creates the lint to the image. Works fine.

Now that is the issue.

When I click on Update button after having changed the image, the image is removed and replaced by the file_id. Since there is not table rendering function to be called the image is replaced by the simple id.

How can I override this behaviour?

ty
f

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 63,803Questions: 1Answers: 10,515 Site admin
    Answer ✓

    With standalone editing you would need to use postEdit to update the document with a suitable img tag. In standalone mode Editor just writes the value given to it without passing it through a rendering function (actually, this is also the case when used with DataTables - it rendering functions for display are normally part of the DataTable).

    Allan

  • fabioberettafabioberetta Posts: 74Questions: 23Answers: 4
    edited June 2016

    Hello Allan,

    thanks for the suggestion. I tried it out and it worked but I still have an issue.

    In order to make it work I had to do the following:

    edAccount.on( 'postEdit', function ( e, json, data ) {
                
                var doc = getWebLink ( data.file_id );
                var _link = "<?php echo getenv('DOCUMENT_PATH').'/'.$_SESSION['account_id'].'/'; ?>" + data.file_id + '.' + doc[0].file_extension;              
                
                $('[data-editor-field="file_id"]').get(0).innerHTML = '<img src="' + _link + '" width=128 />' ;
                
            } );
    

    As you can see I had to call a function getWebLink that makes an ajax call to retrieve the file information that contains the file extension.

    I was wondering if there was any other method to get access to the uploaded file information that are transmitted via ajax by your library. Unfortunately the postEdit function json and data variables contains the id of the file.

    ty
    f

  • allanallan Posts: 63,803Questions: 1Answers: 10,515 Site admin
    Answer ✓

    Currently no - not for standalone editing. The way Editor's upload works is that the file information is exposed via the DataTables API files() method. That's obviously not much use if you are using it without DataTables, and I'm afraid that's a gap in the API at the moment.

    I'm going to introduce a new Editor method in the next version that will also have access to those files, but at the moment an Ajax request is perhaps the best way to do it without modifying the libraries.

    Allan

This discussion has been closed.