Forum FAQForum FAQSearchSearch MemberlistMemberlist Forum ignore listForum ignore list RegisterRegister ProfileProfile Log in to check your private messagesLog in to check your private messages Log inLog in
jQuery Problemi :(

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side
View previous topic :: View next topic  
Author Message
hrv0j3



Joined: 03 Aug 2007
Posts: 34

PostPosted: 21.06.2009 20:21    Post subject: jQuery Problemi :( Add user to your forum ignore list Reply with quote

Poz svima opet Smile

Imam jedan problem koji nikako da rijesim...

Prvo opis sto se desava:
- Imam npr. 10 artikala iz baze.
- svaki artikal ima detalje
- kad se klikne na artikal otvara se div (iznad svega) s detaljima tog artikla
- div se zatvara na klik (close)

Kod koji koristim:

jQuery:
Code:

$(function(){
 $('a.artikal-detalji').click(function()
 {
    var width = $(this).width();
    var height = $(this).height();
    var top = $(this).offset().top;
    var left = $(this).offset().left;
    var partnum = $(this).attr('href');
   
$.post("inc/artikli-detalji.php", { var: partnum }, function(data){
 alert(data);
 $("#detalji").html(data);
 } );
   
    $('#detalji').css({ "top":top, "left":left, "position":"absolute" });
    $('#detalji').fadeIn(600);
   return false;
 });
});


artikli-detalji.php
Code:

<?php echo 'test'; ?>


Sto je problem?
U IE ne radi nimalo Smile (kliknem na artikal da dobijem detalje no IE mi to prepoznaje kao klikanje na link te me prebacuje na url (href)

Dakle.. zasto u FF3 radi kako treba... dok u IE jednostavno ne prepoznaje jquery te samim time klik za detalje prepoznaje kao URL (href).

hvala!
Back to top
View user's profile Send private message MSN Messenger
hrv0j3



Joined: 03 Aug 2007
Posts: 34

PostPosted: 22.06.2009 02:24    Post subject: Add user to your forum ignore list Reply with quote

problem rijesen:

Code:
$.post("inc/artikli-detalji.php", { [b]var[/b]: partnum }, function(data){


rijesenje:
Code:
$.post("inc/artikli-detalji.php", { varijabla: partnum }, function(data){


Ali sada imam problem 2 Smile

Naime kad se otvori div unutar njega bude ispisan link koji sluzi za skrivanje otvorenog diva:
Code:
<a href="#" id="closeme" style="color:#FFF;">zatvori me</a>


Kod za skrivanje:
Code:
$('#closeme').click(function()
 {
 $('#detalji').fadeOut(600);
 return false;
 });


Medutim kad kliknem na link div se ne zatvara.. ako href stavim ="nesto" onda me redirekta na taj link u hrefu...

pomoc molim! Smile hvala!
Back to top
View user's profile Send private message MSN Messenger
r3dsc0rpi0n



Joined: 20 Apr 2005
Posts: 354
Location: Zagreb

PostPosted: 22.06.2009 13:40    Post subject: Add user to your forum ignore list Reply with quote

U prvom problemu si koristio reserved word "var" to izbjegavaj Smile

A drugi problem imaš jer ti se DOM promijenio i click event ti se nije zakačio na promijenjeni DOM pošto ga ne vidi...

Koristi built in metodu "live" (u v1.3 je samo)

Code:

$('#jura').live('click', function(){

...


ili bindaj click na neki element koji je od starta uvijek u DOMu (recimo na parent element od tog "closeme" linka) pa gledaj koji je element kliknut

Code:

$('body').click(function(e) {

   $target = $(e.target);

   if($target.is('#jura')){

      do_something();

   }
});


googlaj event delegation, event bubbling

_________________
::: Fortis est, qui se vincit ! ::::
Back to top
View user's profile Send private message Send e-mail Visit poster's website Twitter profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    mi3dot.org Forum Index -> Client-side All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group