2012-04-17 109 views
0

我不確定發生了什麼,但我設置newcontent並嘗試爲每個項目添加一個倒計時它似乎沒有工作,抱歉,不太確定如何解釋它。jQuery倒計時停止頁面顯示

用了這個腳本的倒計時部分看到下面的腳本工作正常

COUNT DOWN PART

$('#countdown'+members[i]['id]']).countDown({ 
          targetDate: { 
          'day':  17, 
          'month': 12, 
          'year':  2012, 
          'hour':  01, 
          'min':  0, 
          'sec':  0, 
          },omitWeeks: true 

         }); 

和腳本

function realcashNowCallback(page_index, jq){ 
       // Get number of elements per pagionation page from form 
       var items_per_page = 8; 
       var max_elem = Math.min((page_index+1) * items_per_page, members.length); 
       var newcontent = ''; 

       // Iterate through a selection of the content and build an HTML string 
       for(var i=page_index*items_per_page;i<max_elem;i++) 
       { 

        memberscountdown = members[i]['enddate']; 
        newcontent += '<div id="offer1" class="realcashnowitems">'+ 
            '<div id="title1" class="moreofferstop">' + members[i]['tradingname'] + '</div>' 
           +' <div id="defaultCountdown" class="moreoffers"> ' 
           +'<div id="pic1" class="productimagesmall"><img style="width:180px;" src="'+ members[i]['picurl']+'"></div>' 
           +'<div id="description1" class="descriptionsmall">'+ members[i]['des']+'</div>' 
           +'<div id="spend1_0" class="spendget1">SPEND $'+members[i]['offers'].split('|')[0].replace('.00', '').replace(' $', '')+'<br/><span>GET $'+members[i]['offers'].split('|')[1].split(',')[0].replace(' $', '').replace('.00', '')+'</span></div>' 
           +'<div id="countdown'+members[i]['id']+'"class="spendget2">'; 


        newcontent += '</div>' 
           +'<div class="buttonmore"><a id="link1" href="'+ members[i]['url'] +'"><img src="template/images/elmos/More_Button.png"></a></div> '   
           +'</div>' 
           +'<div id="sub1" class="moreoffersbottom">'+ members[i]['suburb']+'</div>' 
           +'</div>';  

        $('#countdown'+members[i]['id']).countDown({ 
         targetDate: { 
         'day':  17, 
         'month': 12, 
         'year':  2012, 
         'hour':  01, 
         'min':  0, 
         'sec':  0, 
         },omitWeeks: true 

        }); 

       } 

       // Replace old content with new content 
       $('#Searchresult').html(newcontent); 

       // Prevent click eventpropagation 
       return false; 
      } 
+1

是不是一個錯誤:'$( '#倒計時' +會員[I] [ 'ID]'])'? – Igor 2012-04-17 01:24:09

+0

這是一個錯字 – RussellHarrower 2012-04-17 01:32:34

回答

0

的不知道更多的HTML端關於你的問題和什麼是「不工作」,我認爲這是問題:

$('#countdown['+members[i]['id]']).countDown({ 

應該

$('#countdown['+members[i][id]+']').countDown({ 
+0

除非它應該是$('倒計時'+ members [i] ['id'])。倒計時({...並且它在多個地方。我建議這是唯一的原因 - > members [i] ['enddate']; – Lazerblade 2012-04-17 01:31:37

+0

是的,它似乎你是對的,它應該是'members [i] ['id']'而不是'members [i] ['enddate']' – Igor 2012-04-17 01:36:43