{"action":"created","issue":{"url":"https://api.github.com/repos/CliffCloud/Leaflet.EasyButton/issues/22","labels_url":"https://api.github.com/repos/CliffCloud/Leaflet.EasyButton/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/CliffCloud/Leaflet.EasyButton/issues/22/comments","events_url":"https://api.github.com/repos/CliffCloud/Leaflet.EasyButton/issues/22/events","html_url":"https://github.com/CliffCloud/Leaflet.EasyButton/issues/22","id":92330876,"number":22,"title":"Change state","user":{"login":"n0ne","id":783906,"avatar_url":"https://avatars.githubusercontent.com/u/783906?v=3","gravatar_id":"","url":"https://api.github.com/users/n0ne","html_url":"https://github.com/n0ne","followers_url":"https://api.github.com/users/n0ne/followers","following_url":"https://api.github.com/users/n0ne/following{/other_user}","gists_url":"https://api.github.com/users/n0ne/gists{/gist_id}","starred_url":"https://api.github.com/users/n0ne/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/n0ne/subscriptions","organizations_url":"https://api.github.com/users/n0ne/orgs","repos_url":"https://api.github.com/users/n0ne/repos","events_url":"https://api.github.com/users/n0ne/events{/privacy}","received_events_url":"https://api.github.com/users/n0ne/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-01T09:43:28Z","updated_at":"2015-07-01T19:22:33Z","closed_at":"2015-07-01T19:22:33Z","body":"Hi.\r\nTell me, please, have any the possibilities to change the state of the button, without pressing the button? for example, I have a single-page application, and when I click on the \"Home\" link, the button state must be changed to default"},"comment":{"url":"https://api.github.com/repos/CliffCloud/Leaflet.EasyButton/issues/comments/117800060","html_url":"https://github.com/CliffCloud/Leaflet.EasyButton/issues/22#issuecomment-117800060","issue_url":"https://api.github.com/repos/CliffCloud/Leaflet.EasyButton/issues/22","id":117800060,"user":{"login":"atstp","id":5891072,"avatar_url":"https://avatars.githubusercontent.com/u/5891072?v=3","gravatar_id":"","url":"https://api.github.com/users/atstp","html_url":"https://github.com/atstp","followers_url":"https://api.github.com/users/atstp/followers","following_url":"https://api.github.com/users/atstp/following{/other_user}","gists_url":"https://api.github.com/users/atstp/gists{/gist_id}","starred_url":"https://api.github.com/users/atstp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/atstp/subscriptions","organizations_url":"https://api.github.com/users/atstp/orgs","repos_url":"https://api.github.com/users/atstp/repos","events_url":"https://api.github.com/users/atstp/events{/privacy}","received_events_url":"https://api.github.com/users/atstp/received_events","type":"User","site_admin":false},"created_at":"2015-07-01T19:22:33Z","updated_at":"2015-07-01T19:22:33Z","body":"Yeah, for sure.  First, make sure you're using [v1](https://github.com/CliffCloud/Leaflet.EasyButton/tree/v1-dev) &mdash; you probably know that, but i'll be verbose for anyone else who sees this.\r\n\r\nWith v1, you'll define your button like this:\r\n```\r\n/*\r\n * because you'll need the button later,\r\n * attaching it to the window will make sure any \r\n * spa scoping doesn't get in the way\r\n */\r\nwindow.buttonWithHomeState = L.easyButton({  \r\n  states: [{\r\n    stateName: 'home',   // this is the name of the button's state\r\n    icon: 'fa-home',\r\n    title: 'add random markers',\r\n    onClick: function(btn) {\r\n      btn.state('other-not-home-state')\r\n    }\r\n  }, {\r\n    stateName: 'other-not-home-state',\r\n    icon: 'fa-question-circle',\r\n    onClick: function() {\r\n      // do something else\r\n    },\r\n    title: 'remove markers'\r\n  }]\r\n});\r\n```\r\n\r\nand from anywhere (probably click listener or home-nav hook), you'll be able to:\r\n```\r\nwindow.buttonWithHomeState.state('home');  // go a specific state by name\r\n```\r\n\r\nGood luck! Let me know how this works out, if there's trouble, let me know which spa framework you're using and i'll send something more specific to that."}}