Trigger another submit during submitSuccess
Trigger another submit during submitSuccess
Hi Alan,
When a user crosses one product with another that happens to have another instance within the context they're working in I'd like to cascade this change. The way I'm attempting to get it to work is by sending back the duplicate entity's unique ID on with the other information back to Editor. If json.more is defined then I know to trigger the cascade.
on("submitSuccess", function() {
...
if (typeof json.more !== 'undefined') {
moreToCross.more = json.more;
moreToCross.catalogId = json.catalogId;
}
...
After handling some other items (finishing up on what it was operating on to begin with) I try to trigger a new submit event based on the info sent back.
if ( !$.isEmptyObject(moreToCross) ) {
killLoader();
var tr = $("tr#"+moreToCross.more)[0],
offeredItem = "#CRVID#"+moreToCross.catalogId;
editor
.edit(tr, false)
.set({
'offerItem': offeredItem
})
.submit();
}
The variables log correctly and no errors are thrown, yet the submission never occurs. Is it incapable of submitting before hitting the precise end of the methods flow?
Thanks for any insight-
This question has an accepted answers - jump to answer
Answers
Quickly answered my own question :p Looks like it's just incapable of calling the
submit()
event before one is completed entirely. I wrapped the function in a 100ms timeout and voila.Thanks anyway!
Interesting - it should actually be possible to do that at that point.
submitComplete
might be better since it is the final event that will be triggered, but it should still be possible. I'll try it locally. However, good to hear you have a workaround for now.Allan