Extend 'action' or customize request from Editor instance
Extend 'action' or customize request from Editor instance
I'm aware you can "extend" the data sent to the server inside Editor's ajax
function. I've done it! $.extend(data, {...})
If I am outside the ajax
function, and I wanted to extend the data, how could I do that?
For example, I want to set a custom action, or include extra data in the request... could I do it through the editor instance somehow?
// pseudo-code example:
editor
.create(false)
.setAction('custom-action-name')
.set('customFieldForDBProcessing', 420)
.submit();
I think we must use edit
, create
, and delete
. I want to do a specific sort of edit, but call it something like "upsert"..... but I want the fancy DT/DTE visual transition. Basically, the server needs to see it as an "upsert", but Editor should continue to treat it like an "edit".
This question has an accepted answers - jump to answer
Answers
It sounds like the
initSubmit
event is what you want.There is also
preSubmit
which lets you directly modify the data set to the server. The difference is thatinitSubmit
would be used if you want to use the Editor API to set the values, whilepreSubmit
is used after the data has been read from the form.Allan
@allan
Those have been useful to me in the past. I later found these success/error callback functions for
.sbumit()
(below).Where are these submit callback functions processed (example below)? In the aforementioned events,
submitError
, orsubmitSuccess
? If so, how do I pass in the callbacks shown below to wherever they are fired?I'd like to pass in parameters to these callbacks -- for example -- a reference to a modal that's on the screen, so I can close it. I think they take 1 param, which is the data that was received from the server. Can I add extra?
Is there a better way to write this?
The callbacks are called immediately prior to their corresponding events. For example your success callback (first parameter passed into
submit()
) will be called just prior to thesubmitSuccess
event.Generally I tend to use the events rather than the callbacks. It means you can submit in ways other than using the API (e.g. using KeyTable with inline editing).
You can't pass extra parameters into them. It is Editor that passes parameters into them.
Instead you would have a reference to your modal and just call it there - e.g.:
Allan
@allan
I think you are my most favorite coder on the planet.
I have learned so much about JavaScript just in dealing with the DT/DTE framework.
You are the best, Happy Holidays, and Cheers!
Haha - thank you .
Happy Holidays!
Allan