Klaus Hartl schrieb:
> Alexander Petri schrieb:
>> Hi,
>> i built a very small Demosite using CodeIgniter and jQuery.
>>
>> http://www.konzept-b.net/ci_2/index.php
>>
>> As you can see there is a strange effect if you click on "Kommentar"...
>> on IE first it slides up, and then down.
>> on FF it jumps up and down.
>> could anyone help me to let that work smooth?
>>
>>
>> // JavaScript Document
>> $(document).ready(function(){
>>      $("[EMAIL PROTECTED]'kommentar\']").click(function(e){
>>              e.preventDefault();
>>              var href=$(this).href();
>>              var me = this;
>>              $.get(href,function(r) {
>>                      $(me).parent().next().html(r);
>>                      $(me).parent().next().slideDown("slow");
>>              });
>>              
>>              $(this).html("hide comments");
>>              $(this).unbind("click");
>>              $(this).toggle(function(){
>>                      //alert($(this).next().html());
>>                      $(this).parent().next().slideUp("slow");
>>                      $(this).html("show comments");
>>              },function(){
>>                      $(this).parent().next("div").slideDown("slow");
>>                      $(this).html("hide comments");
>>              });
>>      });
>> });
> 
> Alexander, right now I have only condensed the code a bit - more 
> chaining for better performance:
> 
> $(document).ready(function(){
>      $("[EMAIL PROTECTED]'kommentar']").click(function(e) {
>          e.preventDefault();
>          var me = this;
>          var href = this.href;
>          $.get(href, function(r) {
>              $(me).parent().next().html(r).slideDown("slow");
>          });
>          $(this).html("hide comments").toggle(function() {
>              //alert($(this).next().html());
>              $(this).html("show 
> comments").parent().next("div").slideUp("slow");
>          }, function() {
>              $(this).html("hide 
> comments").parent().next("div").slideDown("slow");
>          });
>      });
> });
> 
> Funny, I'm working on a similiar thing right now, so I will get back to 
> you soon... :-)

Just turn around the order of the functions in toggle:

$(this).html("hide comments").toggle(function() {
     $(this).html("hide comments").parent().next("div").slideDown("slow");
}, function() {
     $(this).html("show comments").parent().next("div").slideUp("slow");
});


 From the API docs: The first function is going to be executed on every 
even click (0,2,...), the second function on every odd click...

This is a bit misleading in the docs, because I would think the first 
click is 1, thus odd.


-- Klaus

_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to