Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [jquery] własna lista rozwijana
phpowiec84
post
Post #1





Grupa: Zarejestrowani
Postów: 101
Pomógł: 2
Dołączył: 10.12.2010

Ostrzeżenie: (0%)
-----


wykonałem własną liste rozwijaną (autocomplete <ul><li>) która zawiera podpowiedzi dla danego pola ,
jak wykryć kliknięcie po za listą <ul> aby ją ukryć ?
Go to the top of the page
+Quote Post
vokiel
post
Post #2





Grupa: Zarejestrowani
Postów: 2 592
Pomógł: 445
Dołączył: 12.03.2007

Ostrzeżenie: (0%)
-----


Wykryj kliknięcie na document, a z tego odfiltruj kliknięcie w obrębie ul
Go to the top of the page
+Quote Post
phpowiec84
post
Post #3





Grupa: Zarejestrowani
Postów: 101
Pomógł: 2
Dołączył: 10.12.2010

Ostrzeżenie: (0%)
-----


z tym kliknięciem na dokument rozumiem ,tylko niewiem jak "odfiltrować kliknięcie w ul" (IMG:style_emoticons/default/sad.gif)
Go to the top of the page
+Quote Post
vokiel
post
Post #4





Grupa: Zarejestrowani
Postów: 2 592
Pomógł: 445
Dołączył: 12.03.2007

Ostrzeżenie: (0%)
-----


Korzystasz z jQuery, tak?

[JAVASCRIPT] pobierz, plaintext
  1. $(document).on('click',function(){
  2. var $this = $(this);
  3. if ( $this.not('#ul_id') ){
  4. // ok
  5. }else{
  6. // ignore
  7. }
  8. });
[JAVASCRIPT] pobierz, plaintext


Ten post edytował vokiel 28.12.2011, 22:28:40
Go to the top of the page
+Quote Post
phpowiec84
post
Post #5





Grupa: Zarejestrowani
Postów: 101
Pomógł: 2
Dołączył: 10.12.2010

Ostrzeżenie: (0%)
-----


Tak ,korzystam z Jquery
ale niestety nie działa,powoduję błąd javascript (IMG:style_emoticons/default/sad.gif) (
Go to the top of the page
+Quote Post
PlayKiller
post
Post #6





Grupa: Zarejestrowani
Postów: 29
Pomógł: 3
Dołączył: 16.10.2008

Ostrzeżenie: (0%)
-----


Spróbuj tak:

[JAVASCRIPT] pobierz, plaintext
  1. $(document).click(function(){
  2. if ($(this).not('#ul_id') )
  3. {
  4. alert('poza lista')
  5. }
  6. else
  7. {
  8. alert('w liscie');
  9. }
  10. });
[JAVASCRIPT] pobierz, plaintext
Go to the top of the page
+Quote Post
phpowiec84
post
Post #7





Grupa: Zarejestrowani
Postów: 101
Pomógł: 2
Dołączył: 10.12.2010

Ostrzeżenie: (0%)
-----


Dostaję alert po za listą (IMG:style_emoticons/default/sad.gif)

Go to the top of the page
+Quote Post
vokiel
post
Post #8





Grupa: Zarejestrowani
Postów: 2 592
Pomógł: 445
Dołączył: 12.03.2007

Ostrzeżenie: (0%)
-----


Może tak:
[JAVASCRIPT] pobierz, plaintext
  1. $(document).on('click', function(e) {
  2. var clicked = $(e.target);
  3. if ( clicked.attr('id') == 'ul_id'){
  4. // w obrębie listy ul
  5. }else{
  6. // poza listą
  7. }
  8. });
[JAVASCRIPT] pobierz, plaintext


Ten post edytował vokiel 29.12.2011, 17:43:56
Go to the top of the page
+Quote Post
phpowiec84
post
Post #9





Grupa: Zarejestrowani
Postów: 101
Pomógł: 2
Dołączył: 10.12.2010

Ostrzeżenie: (0%)
-----


wtedy konsola wypluwa mi : Uncaught TypeError: Object #<Object> has no method 'on' , dla document
Go to the top of the page
+Quote Post
vokiel
post
Post #10





Grupa: Zarejestrowani
Postów: 2 592
Pomógł: 445
Dołączył: 12.03.2007

Ostrzeżenie: (0%)
-----


Podepnij jQuery w wersji 1.7, bo pewnie korzystasz ze starej
Go to the top of the page
+Quote Post
PlayKiller
post
Post #11





Grupa: Zarejestrowani
Postów: 29
Pomógł: 3
Dołączył: 16.10.2008

Ostrzeżenie: (0%)
-----


Przecież to jest ciągle ten sam kod, tylko napisany w inny sposób. Źle podpinasz to pod HTML, skoro nie działa. Pokaż jak to wygląda.

Ten post edytował PlayKiller 29.12.2011, 21:54:22
Go to the top of the page
+Quote Post

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: 18.09.2025 - 19:10