javascript - How to get the code in promise object success function to execute before the code after that call? -


I have a named handhold in the function. In the I function I call any other function InsertBlankWidget, which is a definite return on the return of the promised object The function implements. The problem is that BlankWidget is being executed before code in the promised object after calling the code to insert the Widget WidgetDrop in the handle code. After inserting the call, after the success of the promise object to execute the code before BlankWidget (), how can I undo it and execute the code in the function.

  Handliddreaddrop: Function () {// Some lines this.insertBlankWidget (); // lines after insertBlankWidget call} insertBlankWidget: function () {var promise = this.getWidgetModel (); Promise .Done (function () {// code which must be executed before the rows after insertBlankWidget}); }  

To do this, you must return the promise from the insertBlankWidget :

  insertBlankWidget: function () {var prompts on code> .done  function. Promise = this.getWidgetModel (); Promise .Done (function () {// code which must be executed before the rows after insertBlankWidget}); Return promise; }  

Then you will be able to chain in handleWidgetDrop :

  handleWidgetDrop: function () {// some lines InertBlankWidget () Done (function () {// insertBlankWidget call after line}}; }  

Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -