{"action":"created","issue":{"url":"https://api.github.com/repos/jeromegn/Backbone.localStorage/issues/135","labels_url":"https://api.github.com/repos/jeromegn/Backbone.localStorage/issues/135/labels{/name}","comments_url":"https://api.github.com/repos/jeromegn/Backbone.localStorage/issues/135/comments","events_url":"https://api.github.com/repos/jeromegn/Backbone.localStorage/issues/135/events","html_url":"https://github.com/jeromegn/Backbone.localStorage/issues/135","id":36461142,"number":135,"title":"Allow override sync method using options","user":{"login":"w0rm","id":43472,"avatar_url":"https://avatars.githubusercontent.com/u/43472?v=3","gravatar_id":"","url":"https://api.github.com/users/w0rm","html_url":"https://github.com/w0rm","followers_url":"https://api.github.com/users/w0rm/followers","following_url":"https://api.github.com/users/w0rm/following{/other_user}","gists_url":"https://api.github.com/users/w0rm/gists{/gist_id}","starred_url":"https://api.github.com/users/w0rm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/w0rm/subscriptions","organizations_url":"https://api.github.com/users/w0rm/orgs","repos_url":"https://api.github.com/users/w0rm/repos","events_url":"https://api.github.com/users/w0rm/events{/privacy}","received_events_url":"https://api.github.com/users/w0rm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-06-25T09:11:10Z","updated_at":"2015-06-01T08:46:50Z","closed_at":null,"body":"I have a session model, that I need to sync with both back-ends (api endpoint and localStorage).\r\n\r\nIt could be good to choose sync method not only based on `model.localStorage || (model.collection && model.collection.localStorage)` expression, but also based on `options` object. What do you think of this change?\r\n\r\n```\r\nBackbone.getSyncMethod = function(model, options) {\r\n  if(model.localStorage || (model.collection && model.collection.localStorage)) {\r\n    if(!options || !options.syncMethod || options.syncMethod === 'localStorage') { \r\n       return Backbone.localSync;\r\n    }\r\n  }\r\n\r\n  return Backbone.ajaxSync;\r\n};\r\n\r\n// Override 'Backbone.sync' to default to localSync,\r\n// the original 'Backbone.sync' is still available in 'Backbone.ajaxSync'\r\nBackbone.sync = function(method, model, options) {\r\n  return Backbone.getSyncMethod(model, options).apply(this, [method, model, options]);\r\n};\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/jeromegn/Backbone.localStorage/issues/comments/107370222","html_url":"https://github.com/jeromegn/Backbone.localStorage/issues/135#issuecomment-107370222","issue_url":"https://api.github.com/repos/jeromegn/Backbone.localStorage/issues/135","id":107370222,"user":{"login":"nerdgore","id":1582533,"avatar_url":"https://avatars.githubusercontent.com/u/1582533?v=3","gravatar_id":"","url":"https://api.github.com/users/nerdgore","html_url":"https://github.com/nerdgore","followers_url":"https://api.github.com/users/nerdgore/followers","following_url":"https://api.github.com/users/nerdgore/following{/other_user}","gists_url":"https://api.github.com/users/nerdgore/gists{/gist_id}","starred_url":"https://api.github.com/users/nerdgore/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nerdgore/subscriptions","organizations_url":"https://api.github.com/users/nerdgore/orgs","repos_url":"https://api.github.com/users/nerdgore/repos","events_url":"https://api.github.com/users/nerdgore/events{/privacy}","received_events_url":"https://api.github.com/users/nerdgore/received_events","type":"User","site_admin":false},"created_at":"2015-06-01T08:46:50Z","updated_at":"2015-06-01T08:46:50Z","body":"#166 implemented the option `{ajaxSync: true}`"}}