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 / Ajax pitanjce

 
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
strija



Joined: 14 Sep 2003
Posts: 473
Location: Čakovec

PostPosted: 30.10.2006 14:40    Post subject: JQuery / Ajax pitanjce Add user to your forum ignore list Reply with quote

Radim jednu jednostavnu aplikaciju sa JQuery libraryom i trebao bi malu pomoc.
Dakle imam jednu listu s elementima koja se kreira dinamicki iz baze, i ta lista izgleda otprilike ovako:
Code:

<ul id="promotions">
    <li><a href="#" class="toggle">Ime promocije</a></>
    <form class="detail" method="post" action="promotions_details.php">
        <input type="hidden" name="id" class="id" value="<?=$r -> id?>" />
    </form>
    <div class="details"></div></li>
   
    <li><a href="#" class="toggle">Ime promocije</a></>
    <form class="detail" method="post" action="promotions_details.php">
        <input type="hidden" name="id" class="id" value="<?=$r -> id?>" />
    </form>
    <div class="details"></div></li>
   
    ...
    ...

</ul>


I sad stavljam da se na $("#promotions a.toggle").click() event poziva submit forme $("form.detail"), i to sam napravio ovako:
Code:

$("#promotions a.toggle").click(function() {
    $(this).parent("li").children("form .detail").submit();
});


Forma se submita preko ajax-a ovako:
Code:

$("#promotions form.detail").submit(function() {
   $(this).parent("li").addClass("toggle-loading");
   promotions[$(this).children("input .id").val()] = $(this).parent("li");
   $.ajax({
      type: "POST",
      url: $(this).attr("action"),
      data: "id=" + $(this).children("input .id").val(),
      dataType: "html",
      success: function( html ) {
         $("div.details").html( html );
         $("div.details").slideDown("slow");
      } //end success
   });
   return false;
});


Sad bi trebao nekako referencirati onaj div koji ima class details (<div class="details"></div>) unutar <li> elementa, ali neznam kako da u ovu $.ajax() funkciju za success proslijedim taj element.
Znaci u success: function( html ) {} bi trebao nekako proslijediti ovaj $(this) koji je u $.ajax().

Ako netko zna bio bih mnogo zahvalan na pomoci Smile
Thnx!

_________________
We can exist in ambiguity, but it means the deepest loneliness. | creolab.hr | thefarewellreason.com
Back to top
View user's profile Send private message Visit poster's website
Sulien



Joined: 04 Jan 2004
Posts: 2905
Location: Zagreb

PostPosted: 30.10.2006 15:50    Post subject: Add user to your forum ignore list Reply with quote

Uh, trebalo mi je da dešifriram pitanje Confused
Sljedeći put right to the point, please Smile

Code:
$("#promotions form.detail").submit(function() {
   var li = $(this).parent("li").addClass("toggle-loading");
   var id = $(this).children("input .id").val();
   promotions[id] = li;

   $.ajax({
      type: "POST",
      url: $(this).attr("action"),
      data: "id=" + id,
      dataType: "html",
      success: function( html ) {
         $(li).children("div.details").html(html).slideDown("slow");
      }
   });
   return false;
});

my guess - nikad nisam radio sa jQuery, ružan mi je Razz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
strija



Joined: 14 Sep 2003
Posts: 473
Location: Čakovec

PostPosted: 30.10.2006 16:41    Post subject: Add user to your forum ignore list Reply with quote

Thnx radi, nisam se ovog sjetio, tako je kad nenaspavan ides programirat Smile
Je, JQuery je ruzan ali dosta koristan za ovak neke aplikacije Smile
Uglavnom thnx!

_________________
We can exist in ambiguity, but it means the deepest loneliness. | creolab.hr | thefarewellreason.com
Back to top
View user's profile Send private message Visit poster's website
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