{"action":"created","issue":{"url":"https://api.github.com/repos/seiyria/bootstrap-slider/issues/901","repository_url":"https://api.github.com/repos/seiyria/bootstrap-slider","labels_url":"https://api.github.com/repos/seiyria/bootstrap-slider/issues/901/labels{/name}","comments_url":"https://api.github.com/repos/seiyria/bootstrap-slider/issues/901/comments","events_url":"https://api.github.com/repos/seiyria/bootstrap-slider/issues/901/events","html_url":"https://github.com/seiyria/bootstrap-slider/issues/901","id":393027399,"node_id":"MDU6SXNzdWUzOTMwMjczOTk=","number":901,"title":"Programmatically setValue is not persistent after refresh","user":{"login":"pimlie","id":1067403,"node_id":"MDQ6VXNlcjEwNjc0MDM=","avatar_url":"https://avatars3.githubusercontent.com/u/1067403?v=4","gravatar_id":"","url":"https://api.github.com/users/pimlie","html_url":"https://github.com/pimlie","followers_url":"https://api.github.com/users/pimlie/followers","following_url":"https://api.github.com/users/pimlie/following{/other_user}","gists_url":"https://api.github.com/users/pimlie/gists{/gist_id}","starred_url":"https://api.github.com/users/pimlie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pimlie/subscriptions","organizations_url":"https://api.github.com/users/pimlie/orgs","repos_url":"https://api.github.com/users/pimlie/repos","events_url":"https://api.github.com/users/pimlie/events{/privacy}","received_events_url":"https://api.github.com/users/pimlie/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-12-20T12:32:49Z","updated_at":"2018-12-27T11:21:37Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Is the slider value supposed to be always persistent after calling refresh? The docs does not say anything about this.\r\n\r\nThe problem is that when you call `refresh` after a `setValue()`, the value of the new slider element will always be reset to the initial/default value. This is because setValue only changes `this._state` and the input element attributes, but not `this.options`. And as both `refresh` and `createNewSlider` functions never check for the current state or the input element value attributes respectively, the value after a programmatical setValue is lost.\r\n\r\nI have a PR ready that adds a boolean argument to `refresh` which sets the current value state as option for the newly created slider element, but I am not sure whether that is the best solution for this (eg maybe the value should be persistent by default?). \r\n\r\nSee below a test case which fails at the moment:\r\n```js\r\n  it(\"value is persistent after refresh(true) when set programmatically\", function() {\r\n  \t// Initialize non-range slider\r\n  \ttestSlider = new Slider(\"#testSlider3\");\r\n\r\n    // Assert value is default\r\n    expect(testSlider.getValue()).toBe(testSlider.defaultOptions.value);\r\n    \r\n    var sliderValue = 9\r\n    testSlider.setValue(sliderValue)\r\n\r\n    // Assert value has changed\r\n    expect(testSlider.getValue()).toBe(sliderValue);\r\n\r\n    // Invoke refresh() method\r\n    testSlider.refresh(true);\r\n\r\n    // Assert value is still changed\r\n    expect(testSlider.getValue()).toBe(sliderValue);\r\n  });\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/seiyria/bootstrap-slider/issues/comments/450132772","html_url":"https://github.com/seiyria/bootstrap-slider/issues/901#issuecomment-450132772","issue_url":"https://api.github.com/repos/seiyria/bootstrap-slider/issues/901","id":450132772,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDEzMjc3Mg==","user":{"login":"pimlie","id":1067403,"node_id":"MDQ6VXNlcjEwNjc0MDM=","avatar_url":"https://avatars3.githubusercontent.com/u/1067403?v=4","gravatar_id":"","url":"https://api.github.com/users/pimlie","html_url":"https://github.com/pimlie","followers_url":"https://api.github.com/users/pimlie/followers","following_url":"https://api.github.com/users/pimlie/following{/other_user}","gists_url":"https://api.github.com/users/pimlie/gists{/gist_id}","starred_url":"https://api.github.com/users/pimlie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pimlie/subscriptions","organizations_url":"https://api.github.com/users/pimlie/orgs","repos_url":"https://api.github.com/users/pimlie/repos","events_url":"https://api.github.com/users/pimlie/events{/privacy}","received_events_url":"https://api.github.com/users/pimlie/received_events","type":"User","site_admin":false},"created_at":"2018-12-27T11:21:37Z","updated_at":"2018-12-27T11:21:37Z","author_association":"CONTRIBUTOR","body":"Another question which remains is how you wish to update the value after a refresh? Should we implement something in `createNewSlider` to get the value from the `<input>`? Or do we 'just' call setValue again? Or do we change the option and set the current value as new option value?\r\n\r\nIf one of you wish to take a look at this that's fine with me too btw :)"}}
{"actor":{"display_login":"pimlie"}}