2014-01-20 3 views
0

내 JS는 :jQuery를주기 고토 옵션

$("#front_events").cycle({ 
     fx:  'scrollHorz', 
     next: '.next', 
     prev: '.prev', 
     speed:500, 
     timeout: 0, 
     before:function(isNext, zeroBasedSlideIndex, slideElement){ 
      var c_list = ''; 
      for(i=1;i<=$("#front_events li").length;i++){ 
       c_list += '<li><a href="#" rel="'+ i +'">'+ i +'</a></li>'; 
      } 
      $("#event_numbers").html(c_list); 
      if(slideElement.currSlide == 0){ 
      $("div.day_calendar div.day_select_wrapper ul li a:eq(0)").addClass('active'); 
      } 
     }, 
     after:function(isNext, zeroBasedSlideIndex, slideElement){ 
      var index = slideElement.currSlide + 1; 
      var tarih = $(this).find('a.day_location').attr('rel'); 

      $("div.day_calendar div.day_select_wrapper ul li a").each(function(){ 
       if($(this).attr('rel') == index){ 
        $(this).addClass('active'); 
       }else{ 
        $(this).removeClass('active'); 
       } 
      }); 
      tarih = tarih.split("|"); 
      var t_html = '<div class="day">' + tarih[0] + '</div><div class="month">'+ tarih[1] +'</div><div class="dayname">'+ tarih[2] +'</div>'; 
      $("#calendar_date").html(t_html); 
     } 

    }); 

내가 원하는 wonderful.But 내가 a 태그를 클릭하면 그것은 작품, 그 이미지로 이동합니다. 나는이 페이지를 찾을 수 :

JQUERY CYCLE GOTO2

을 그리고 내 코드 업데이트 : = $ ('#의 event_numbers') 기원전

VAR을;

그리고 추가 :

$container.children().each(function(i) { 
     // create input 
     $('<li><a href="#" rel="'+ i +'">'+ i +'</a></li>') 
      // append it to button container 
      .appendTo(bc) 
      // bind click handler 
      .click(function() { 
       // cycle to the corresponding slide 
       $container.cycle(i); 
       return false; 
      }); 
    }); 

하지만 내 탐색 버튼을 추락했다. DevTools를 통해 확인할 때 다음 오류가 발생합니다.

$container is not defined 

문제가 해결되지 않았습니다.

버튼을 클릭하면 어떻게 추가 할 수 있습니까?

지정한 링크에서

답변

0

, 나는 유일한 차이점은 당신이 같은 변수에주기 객체 반환 값을 저장 놓친 것입니다 볼 수 있습니다

var $container = $('#container').cycle({ 
    fx:  'scrollHorz', 
    speed: 300, 
    timeout: 0 
}); 

코드는해야한다 :

var $container = $("#front_events").cycle({ 
    fx:  'scrollHorz', 
    next: '.next', 
    prev: '.prev', 
    speed:500, 
    timeout: 0, 
    ......