placeholder-enhanced icon indicating copy to clipboard operation
placeholder-enhanced copied to clipboard

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

Open nwhittaker opened this issue 11 years ago • 5 comments

nwhittaker avatar Oct 31 '13 20:10 nwhittaker

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

dciccale avatar Nov 01 '13 12:11 dciccale

@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

nwhittaker avatar Nov 01 '13 15:11 nwhittaker

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

dciccale avatar Nov 15 '13 16:11 dciccale

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().

dartmouthalex avatar Mar 20 '15 16:03 dartmouthalex

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.

dciccale avatar Mar 23 '15 13:03 dciccale