Backbone.js, the framework underlying SuiteCommerce’s frontend logic. Backbonej.js defaults to asynchronous saves, which is a behavior that generally keeps the UI responsive. However, there are cases (such as multi-step data updates or sequential dependencies) where you need to ensure a model is fully saved before executing the next step. Here, I will explore how to override that default behavior and force a synchronous save.
Note: I do not recommend saving models synchronously unless you have to. It is rare for this to be a best practice solution.
Documentation for Backbone model.save() function: Backbone.js
The Backbone “save” function on Models runs asynchronously by default. There may be times when you want this call to run synchronously. See the code block below for the required parameter in that case.
NOTE: “async” MUST be passed in the second argument for it to be read as an argument of the function rather than an attribute on the model.
Dependent workflows: e.g., create, then immediately fetch related data.
Sequential UI updates: e.g., increment counters only after save confirmation.
Caution: Browsers may warn about synchronous requests blocking the UI.
While Backbone’s default async save behavior is good for most scenarios, by setting async: false
, you gain control. However, you must balance it against potential UI blockage and performance effects.
If you liked this article, you'll LOVE our book on SuiteCommerce! Order the free SuiteCommerce book today, and we'll even pay for shipping!
If you have general questions about SuiteCommerce or more specific questions about how our team can support your business as you implement NetSuite or SuiteCommerce, feel free to contact us anytime. Anchor Group is a certified Oracle NetSuite Alliance Partner and Commerce Partner equipped to handle all kinds of NetSuite and SuiteCommerce projects, large or small!
We are a premium SuiteCommerce agency that creates powerful customer portals. Unlike our competitors, we have already solved your problems.
Tagged with Training