.textinput('refresh') #5708

Closed
JorisDebonnet opened this Issue Feb 27, 2013 · 9 comments

Projects

None yet

4 participants

@JorisDebonnet

Could you add a refresh method for text inputs, so that the new clear button (data-clear-btn="true") can be redetermined when the value changes outside of the input's own control?

See my example: http://jsfiddle.net/w83pZ/

@jaspermdegroot
Member

@JorisDebonnet

Thanks for submitting the issue. All widgets should have a refresh method so I agree we have to add this for textinput.

@poonkave

@JorisDebonnet
a workaround for this is to trigger 'change'

http://jsfiddle.net/johnchacko/w83pZ/1/

submitted a pull request
#5763

@JorisDebonnet

True, but there was some reason I didn't want to use change - probably because I had another event handler on that, which would have caused an unnecessary ajax request or something. So in the absense of the refresh method, my current workaround is triggering keyup on the element instead.

@poonkave

@JorisDebonnet , ur right...

#5766

@jaspermdegroot
Member

Slightly related: the clear button should be hidden again after form reset. See @weisborg his comment here #1834 (comment)

@JorisDebonnet

Which probably only means that the fields should be 'refreshed' after form reset -- since a clear button might actually remain if the textfield's default value is not empty.

@jaspermdegroot
Member

@JorisDebonnet

In most cases that will be sufficient. However, in general the refresh method provides the possibility to set all options on the fly. For example: if someone uses a form validator and wants to programmatically change the theme to highlight an input, that should be possible with refresh

@DzenisevichK

Will be also good to re-run autogrow code for textarea in refresh() method...

@poonkave poonkave added a commit to poonkave/jquery-mobile that referenced this issue May 28, 2013
@poonkave poonkave Update textinput.js
reference to issue #5708 
and previous pull request. 
#5766 
added 'refresh' method to textinput. 
added a _private method '_refresh' and called same from create and refresh. 

demo test page :http://jsbin.com/edidil/7/ [Got various combinations of input fields and button to refresh input.] 

demo test page : http://johnchacko.net/samples/textinputs.html
c2606a3
@jaspermdegroot
Member

Closing as fixed on master.

To set an option like clearBtn you should use $( ".selector" ).textinput( "option", "clearBtn", true );. A refresh method has been added for enable/disabled state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment