how can i link object between each other
Can onyone tell me what i'm doing wrong?? In the line 42 I get an error "
t.slider is undefined".
- $(window).load(function()
- {
- var s = $('#GallerySlider');
- if( s.length != 0 )
- {
- var mu = $('img.mu', s); // move up button;
- var md = $('img.md', s); // move down button;
- var sc = $('div.sc', s); // slider content;
- if( mu.lenght == 0 || sc.lenght == 0 || md.lenght == 0 )
- jQuery.error( "ERROR" );
- // slider definition;
- s.content = sc;
- s.items = $('img', sc);
- s.position = 0;
- s.isinmove = false;
- s.step = 98;
- s.sead = 10;
- s.spead = 50;
- s.move = function( direction )
- {
- direction = direction > 0 ? 1 : -1;
- var p = this.position + direction;
- if( p >= 0 - this.items.length + 4 && p <= 0 )
- {
- this.position += direction;
- var margin = this.position * this.step;
- this.content.css( 'margin-top', margin +'px' );
- }
- };
- mu.slider = s;
- md.slider = s;
- mu.slider.move( -1 ); // here it works;
- // move up;
- mu.click( function() {
- var t = $(this);
- t.slider.move( -1 ); // but here it doesn't, i get an error "t.slider is undefined"
- } );
- // move down;
- md.click( function() {
- var t = $(this);
- t.slider.move( 1 );
- } );
- }
- });