nilbus/Backbone.dualStorage

Pre-flight OPTIONS request in offline.

corpulent opened this issue · 2 comments

Great adapter, everything is working. I just have a question. When I am offline and make changes to the models, I can see in the console, that the app is still making an OPTIONS request. This is normal for cross domain requests. But I am not sure if dualStorage should be preventing these requests from being fired. Any thoughts? Thanks.

I think this is outside of the realm of the dualStorage plugin. It attempts to do online operations whenever there are no dirty and destroyed models. To do online operations, it delegates to Backbone.sync, which typically delegates to jQuery.ajax. It does not directly detect on/offline state; it instead treats any ajax errors as if they occurred because the app is offline.

Does this answer your question?

@nilbus Thanks! That makes sense. But why does the pre-flight check not happen if I load the app initially without internet connection? It only happens when I load the app online and then disconnect. Is it possible to set the collection's local flag to true once connection is lost, and false once back online?