Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [jQuery/jqtransform] Dodanie do kodu stylu inputa
einter-project
post
Post #1





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 9.09.2011

Ostrzeżenie: (10%)
X----


Witam

Na stronie muszę zastosować ostylowane formularze. Problem w tym że jest kilka styli tych samych pól formularza. Grafika poniosło.

W jaki sposób przekazać styl z pola do funkcji (korzystam z jqtransform):

Na przykład pole input
<input class="searchInput" type="text" name="searchAccommodation" value="">

I teraz chciałbym nazwę klasy wsadzić w:
$input.addClass("jqTransformInput").wrap('<div class="jqTransformInputWrapper_tutaj nazwe klasy"><div class="jqTransformInputInner"><div></div></div></div>');

  1.  
  2. /***************************
  3. Text Fields
  4. ***************************/
  5. $.fn.jqTransInputText = function(){
  6. return this.each(function(){
  7. var $input = $(this);
  8.  
  9. if($input.hasClass('jqtranformdone') || !$input.is('input')) {return;}
  10. $input.addClass('jqtranformdone');
  11.  
  12. var oLabel = jqTransformGetLabel($(this));
  13. oLabel && oLabel.bind('click',function(){$input.focus();});
  14.  
  15. var inputSize=$input.width();
  16. if($input.attr('size')){
  17. inputSize = $input.attr('size')*10;
  18. $input.css('width',inputSize);
  19. }
  20.  
  21. $input.addClass("jqTransformInput").wrap('<div class="jqTransformInputWrapper_tutaj nazwe klasy"><div class="jqTransformInputInner"><div></div></div></div>');
  22. var $wrapper = $input.parent().parent().parent();
  23. $wrapper.css("width", inputSize+10);
  24. $input
  25. .focus(function(){$wrapper.addClass("jqTransformInputWrapper_focus");})
  26. .blur(function(){$wrapper.removeClass("jqTransformInputWrapper_focus");})
  27. .hover(function(){$wrapper.addClass("jqTransformInputWrapper_hover");},function(){$wrapper.removeClass("jqTransformInputWrapper_hover");})
  28. ;
  29.  
  30. /* If this is safari we need to add an extra class */
  31. $.browser.safari && $wrapper.addClass('jqTransformSafari');
  32. $.browser.safari && $input.css('width',$wrapper.width()+16);
  33. this.wrapper = $wrapper;
  34.  
  35. });
  36. };
  37.  


Bardzo prosiłbym o pomoc jak to rozwiązać.
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
einter-project
post
Post #2





Grupa: Zarejestrowani
Postów: 39
Pomógł: 0
Dołączył: 9.09.2011

Ostrzeżenie: (10%)
X----


Dzięki serdeczne, dla potomnych zmiany w linii 8 i 20, a potem oczywiście trzeba dostosować style do każdej klasy, ale to już nie problem.

Pozdrawiam i jeszcze raz dziękuje za pomoc.


Jeszcze jedno. Mam problem z polem checkbox. Muszę w nim zastosować obsługę funkcji onclick="customerInvoiceVat()". Niestety jak dam onclick to przeładowuje mi stronę, czy jest jakiś sposób aby nie przeładował strony jak się zaznacza to pole.

Pole checkbox;
<input class="RegistrationCheckbox" name="formRegistrationFV" value="1" onclick="customerInvoiceVat()" type="checkbox">

Kawałek kodu odpowiedzialny za to pole:
  1. /***************************
  2. Check Boxes
  3. ***************************/
  4. $.fn.jqTransCheckBox = function(){
  5. return this.each(function(){
  6. if($(this).hasClass('jqTransformHidden')) {return;}
  7.  
  8. var $input = $(this);
  9. var inputSelf = this;
  10. var $inputClass = $input.attr('class');
  11.  
  12. //set the click on the label
  13. var oLabel=jqTransformGetLabel($input);
  14. oLabel && oLabel.click(function(){aLink.trigger('click');});
  15.  
  16. var aLink = $('<a href="#" class="jqTransformCheckbox'+$inputClass+'"></a>');
  17. //wrap and add the link
  18. $input.addClass('jqTransformHidden').wrap('<span class="jqTransformCheckboxWrapper'+$inputClass+'"></span>').parent().prepend(aLink);
  19. //on change, change the class of the link
  20. $input.change(function(){
  21. this.checked && aLink.addClass('jqTransformChecked') || aLink.removeClass('jqTransformChecked');
  22. return true;
  23. });
  24. // Click Handler, trigger the click and change event on the input
  25. aLink.click(function(){
  26. //do nothing if the original input is disabled
  27. if($input.attr('disabled')){return false;}
  28. //trigger the envents on the input object
  29. $input.trigger('click').trigger("change");
  30. return false;
  31. });
  32.  
  33. // set the default state
  34. this.checked && aLink.addClass('jqTransformChecked');
  35. });
  36. };


Pozdrawiam
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 17.10.2025 - 12:51