On Sat, Sep 26, 2009 at 10:18 AM, Matt Quackenbush <quackfu...@gmail.com> wrote:
>
> That code should not work on _any_ browser.  In the onclick attribute you
> are grqbbing a reference to the containing div ($('#followButton2')), which
> clearly has no method named followUser.

... except that he's created his own jQuery extension called "followUser".

Personally I'd be suspicious of the way that the handler is set up (as
a string value for the <a> tag's "onclick" attribute).

Also, in the "followUser" code, I think that the stuff to load the new
page (or whatever that is) should be in the finish handler for the
initial call to "fadeOut()" in order to make things work right.


Try something like this instead:
> <script>
> $(document).ready(function(){
>   $('div a').click(function(){
>        followUser($(this).attr('rel');
>   });
> });
>
>> <div id="followButton2">
>> <a rel="2">test1</a>
>> </div>
>
> Sent from my iPhone
>
> On Sep 26, 2009, at 6:26, indre1 <ind...@gmail.com> wrote:
>
>>
>> Any suggestions, why this code is not working on Webkit browsers:
>>
>> (function($) {
>>  $.fn.followUser = function(userId) {
>>     this.fadeOut(250);
>>     $.get("profile.php", { do: "addfriend", id: userId }, function(data)
>> {
>>         return this.html('<p>Follower added</p>').fadeIn(250);
>>     });
>>
>>  }
>> })(jQuery);
>>
>> Only jquery and the plugin printed above are loaded, so there
>> shouldn't be any conflicts.
>>
>> HTML:
>> <div id="followButton2">
>> <a onclick="$('#followButton2').followUser('2')">test1</a>
>> </div>
>>
>>
>> Chrome gives the following error:
>> Uncaught TypeError: Object #<an Object> has no method 'followUser
>



-- 
Turtle, turtle, on the ground,
Pink and shiny, turn around.

Reply via email to