Hmmm...I'm not sure how to get help around here? Most of my questions  
just go unanswered...wish there was a forum for all of this...

But I did figure out what I needed to do...after a couple hours of  
reading...and alot of fiddling around. It was rather simple all in  
all...this is the completed thing...certainly, if people want to crit  
what I've done here that could be educational...

Thanks...

jQuery.fn.tabpost = function(callback)
{
        $(this).click(function()
        {
                check = $(this).attr('title');

                // call back will go here eventually

                $('#' + $(this).parent().attr('id') + ' li').each(function()
                {
                        $(this).compare(check, $(this).attr('title'));
                });
        });
}

PS: I'm loving Jquery more everyday I get to work with it...



On 10 Feb 2007, at 17:08, Vaska wrote:

> I'm a little unclear about usage of $(this). I have this function
> that currently works but the idea is that I can reuse this for many
> instance (I'll put a callback into this later that will be different
> for each time it's used). What it does (for the moment), is simply
> toggle (highlight) the selected element in a list (LI):
>
> jQuery.fn.tabpost = function()
> {
>       $(this).click(function()
>       {
>               check = $(this).attr('tabindex');
>
>               $('.ajx-thumbs li').each(function() // this line is the problem
>               {
>                       $(this).compare(check, $(this).attr('tabindex')); // 
> sets the
> class to 'active' if true or removes it...
>               });
>
>               return false;
>       });
> }
>
> Works just right, expect that I have '.ajx-thumbs li' specified - I
> need to have the function know what it's dealing with here (as it
> goes through the list). The function is called into action in a
> document ready...
>
> $('.ajx-thumbs li').tabpost();
>
> This is what the html looks like...
>
> <ul class='listed ajx-thumbs'>
> <li id='tab1' tabindex='1'>100</li>
> <li id='tab2' tabindex='2' class='active'>200</li> // active at page
> output
> <li id='tab3' tabindex='3'>300</li>
> <li id='tab3' tabindex='4'>Original</li>
> </ul>
>
> This would be my first actual Jquery function...I could use some
> pointers here I bet. ;)
>
> Any thought?
>
> Thanks...
>
> PS: when completed it will be something like...
>
> $('.ajx-thumbs li').tabpost(callback1);
> $('.ajx-image li').tabpost(callback2);
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to