Forum www.public4you.fora.pl Strona Główna

www.public4you.fora.pl
Forum gazetki blogowej The Public.
 

ghd hair Quirky jQuery - Setting the 'value' attri

 
Napisz nowy temat   Odpowiedz do tematu    Forum www.public4you.fora.pl Strona Główna -> Your opinion
Zobacz poprzedni temat :: Zobacz następny temat  
Autor Wiadomość
per9n53ve
Ten to ma gadanę...
Ten to ma gadanę...



Dołączył: 25 Wrz 2010
Posty: 686
Przeczytał: 0 tematów

Ostrzeżeń: 0/5
Skąd: England

PostWysłany: Wto 2:49, 16 Lis 2010    Temat postu: ghd hair Quirky jQuery - Setting the 'value' attri

,[link widoczny dla zalogowanych]
Personally, I believe this is an ugly work-around. Even changing the 'value' attribute with straight javascript didn't seem to work. So, this is really a javascript quirk I'd love to find a better step around.
alert($(this).parent().html());
Whenever the text changed in the text input, I would create a hidden input with the new value. When the text changed again,[link widoczny dla zalogowanych], the hidden input would be deleted and then added back in. I tried doing this with just the text input (i.e., deleting it,[link widoczny dla zalogowanych], manually adding the value in, and re-outputting it), but when you do that you lose any event bindings. When I went to cache the html,[link widoczny dla zalogowanych], it would look like this:

Since this is what will be pulled from the database, next I need to trigger a switch to replace out the old value of the text input with the value in the hidden input. That's easy enough with jQuery, since we have a 'rel' attribute to link them.
For the 'value' attribute,[link widoczny dla zalogowanych], however, the html doesn't actually deviate. And that little quirk cost me a few hours in research to try to find a toil-around. What I was trying to do was cache a bock of html in a database, but I wanted to retain the value of the text inputs if they changed. Since the 'value' attribute didn't actionually change in the html, I got stuck. Here's what I did to work around it:
This one stumped the guys over at the jQuery IRC channel:
or this:
<input>
<input>

Quirky jQuery - Setting the 'value' attribute in HTML Quirky jQuery - Setting the 'value' attribute in HTML Posted October 17th, 2008 by Chris
$(this).val('value');
When you use the jquery to set an element's value attribute, you can do the folloearng:
For most attributes, this will change the actual html. To test it out, you can use Firebug and watch the value change, or print out the new output by doing something like:
$(this).attr('value', 'newvalue');


Post został pochwalony 0 razy
Powrót do góry
Zobacz profil autora
Wyświetl posty z ostatnich:   
Napisz nowy temat   Odpowiedz do tematu    Forum www.public4you.fora.pl Strona Główna -> Your opinion Wszystkie czasy w strefie EET (Europa)
Strona 1 z 1

 
Skocz do:  
Nie możesz pisać nowych tematów
Nie możesz odpowiadać w tematach
Nie możesz zmieniać swoich postów
Nie możesz usuwać swoich postów
Nie możesz głosować w ankietach


fora.pl - załóż własne forum dyskusyjne za darmo
Powered by phpBB © 2001, 2005 phpBB Group
deoxGreen v1.2 // Theme created by Sopel stylerbb.net & programosy.pl

Regulamin