Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a mechanism for programmatically changing a field's placeholder text. #39

Open
nwhittaker opened this issue Oct 31, 2013 · 5 comments
Labels

Comments

@nwhittaker
Copy link

No description provided.

@dciccale
Copy link
Owner

dciccale commented Nov 1, 2013

@nwhittaker you can't do this already with jQuery? $("#myinput").attr("placeholder", "something else");

@nwhittaker
Copy link
Author

@dciccale Yes, the attribute itself changes, but for non-supporting browsers, the field's placeholder text is not visually updated.

$("#myinput")[0].value; // prints "placeholder text"
$("#myinput").attr("placeholder", "something else");
$("#myinput")[0].value; // prints "placeholder text" -- would expect "something else"
$("#myinput").val(); // prints "placeholder text" -- would expect an empty string

@dciccale
Copy link
Owner

Yes I get it, ok this could be done improving the custom val() function inside the plugin. Is a very important feature, I will implemented asap, if no one else do it before me.

I leave this issue opened until fixed and mark it as a new feature to implement.

Maybe you could modify the title for this issue to something like "update placeholder value when placeholder attribute change" or something like that.

cool @nwhittaker thanks

@dartmouthalex
Copy link

I think @nwhittaker is asking for more than just updating the custom .val() function.

In the example he provided, after:
$('#myinput').attr('placeholder', 'something else');

I would expect
$('#myinput').val();
to return an empty string, but also as @nwhittaker says:
$('#myinput')[0].value
should return "something else", and the user should actually see the new placholder "something else".

That will require more change than just the custom .val().

@dciccale
Copy link
Owner

Well, unless every time the plugin wants to access the placeholder attribute, should always get it without caching it as it is done now. Doing it so, will reduce performance but will always have the latest placeholder value. Unless an extension is made for the attr() function also along with the custom val() but I prefer the first solution have to be tested if it could work for all those cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants