Editor instances

Editor instances

jtoler5jtoler5 Posts: 93Questions: 34Answers: 3
edited December 2015 in Editor

I'm trying to build a inventory/checkout system using Editor. When the new entry button is clicked I have an autocomplete function on the "serial" field that simply searches the database and completes the whole serial. When the serial is selected from the drop down, I have a callback function that searches the currently checked out items. If the serial selected is checked out a warning pops up (on top of the editor modal) that tells them it is currently checked out. They have the option to cancel the new entry all together (closes editor modal) or mark the item returned. My issue is what happens when they click "mark returned"...

I'm currently having to do this, with it waiting a second after closing or else it never even tries to submit the edit. The issue with this is of course that the data entered into the new modal is now gone, which I don't want. I notice that if I don't close editor, it fills in the modal fields with the row editor received from the edit response.

editor.close()

setTimeout( function () {
   editor
       .edit('#' + response[0].id, false)
       .set('return_date', moment().format("YYYY-MM-DD"))
       .submit();
   }, 1000 );

How could I have the 'main' editor modal opened for a new entry and based on what was selected; have editor edit a row in the table in the background?

I thought maybe the easiest way to do this was to leave it as it is but before I close editor have it get the current data in the new modal, after the submit of the edit, open editor and fill back in the fields. How could I create a loop to do all this though? I don't want a whole bunch of editor.get() and editor.set().

I don't know the best way to go about doing this? I'm hoping someone can give me an alternative way.

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    How could I have the 'main' editor modal opened for a new entry and based on what was selected;

    This example shows how you could have a duplicate button.

    have editor edit a row in the table in the background?

    A single Editor instance can only be used for a single action at a time - it can't have the edit window open for one row while editing another in the background for example. That would require two different Editor instances.

    Allan

This discussion has been closed.