Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

.textinput('refresh') #5708

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

.textinput('refresh') #5708

JorisDebonnet opened this issue Feb 27, 2013 · 9 comments

Comments

@JorisDebonnet
Copy link

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
Copy link
Contributor

@JorisDebonnet

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

@poonkave
Copy link
Contributor

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

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

submitted a pull request
#5763

@JorisDebonnet
Copy link
Author

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
Copy link
Contributor

@JorisDebonnet , ur right...

#5766

@jaspermdegroot
Copy link
Contributor

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

@JorisDebonnet
Copy link
Author

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
Copy link
Contributor

@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
Copy link

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

poonkave added a commit to poonkave/jquery-mobile that referenced this issue May 28, 2013
reference to issue jquery-archive#5708 
and previous pull request. 
jquery-archive#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
@jaspermdegroot
Copy link
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants