cordova - Does backbone.localstorage work on mobile with PhoneGap? -
i using cordova-2.7.0 build single page mobile application backbone, require.js, jquery, etc.
i searching way treat form input model, , make collection of model. in other words, wanted save form input local storage until device online. want save data local storage.
so, can use backbone.localstorage
save data works in major mobile devices ios, android, windows-phone , blackberry, etc. or best way save data before can sync them server when device offline?
it nice if point me working examples or repo in github.
yes can go backbone.localstorage. but, not required go library. can using html
, javascript
or jquery while developing phonegap
application.
local storage
work using device cache persistence, , works offline fast.
here's example:
in html
file:
<input type="text" id="abc" name="username"></input> <input type="text" id="xyz" name="password"></input> <input type="submit" id="btn" value="submit" name="submit">submit</input>
in javascript
file:
$(document).on('ready',function() { jquery('.btn').on('click',function() { var username = $("#abc").val(); var password= $("#xyz").val(); window.localstorage.setitem(uname, username ); window.localstorage.setitem(pwd, password); var usname = window.localstorage.getitem('pwd'); }); });
this simple example. can store large amount of data local storage
. can while working offline. when online things local storage
, send api endpoint.
local storage works backbone. here's linke tutorial i'd recommend.
hope got answer.
Comments
Post a Comment