2014-04-01 22 views
0

我需要一些jqueryMobile應用程序的幫助。問題與jquery手機,功能不工作

http://www.mandinker.com/proyects_vip_dev/app-llarjove/

  1. 在這個環節,你會發現一些箱子,點擊名爲 「CALENDARIO」 框。
  2. Okey,一切正常,然後按下dropfoot並轉到「INICIO」。
  3. 再次做第一步,去「CALENDARIO」,和田田,錯誤!

這裏的錯誤:

TypeError: calendario is not a function
...".ui-page-active .calendario").size()){calendario();$( "#datepicker").datepicke...

這裏是相關的源代碼:

$(document).delegate('.ui-page-active', 'pageshow', function() { 
    if($(".ui-page-active .calendario").size()){ 
     calendario(); 
     $("#datepicker").datepicker(); 
    } 
}); 

function makecalendar(){  
    $("#datepicker").datepicker(); 
} 

function calendario(){ 
    makecalendar(); 
    $.ajax({ 
     type: "POST", 
     url: "http://llarjove.softonthecloud.net/calendar", 
     data: {}, 
     error: function(){}, 
     success: function(data) { 
      calendario=data; 
      $(".calendario ul.ui-listview").html(""); 
      $("td").attr("class","ui-datepicker-unselectable"); 
      noticias=data.news; 
      $.each(noticias,function(key,value){    
       tmp=value.fecha.split(" "); 
       tmp=tmp[0].split("-");        
       $("td[data-month="+(parseInt(tmp[1])-1)+"][data-year="+tmp[0]+"] > a").filter(function(){ 
      tmp[2]=tmp[2].replace(/^0+/, "");      
     if($(this).text()==parseInt(tmp[2])){      
      return $(this).text()==parseInt(tmp[2]); 
     };  
     }).css({"background":"#00cae8","color":"white"}).attr("href","./calenItem.html?fecha='"+value.fecha+"'").on("click",function(){window.location.href = "./calenItem.html?fecha='"+encodeURIComponent(value.fecha)+"'";}); 
      }); 
     }, 
     dataType: "json", 
     async: false 
    }); 
    setInterval(function(){ 
     $(".ui-datepicker-calendar").height($(window).height()-$(".ui-header").height()-120); 
    },300); 
} 

任何想法?

+0

是在$(文件)中)calendario功能。就緒(函數({ ..}); ? – system7

+0

或者你也必須把你的函數放在委託函數中。 – system7

+0

函數不在委託和$(document).ready(); datepicker也給我一個錯誤,但datepicker是另一個.js,所以我需要一些重新加載我的.js當應用程序給我一個錯誤 – QuemaGalletas

回答

0

就我所見,您的POST請求僅在第一次點擊「CALENDARIO」時執行。 我建議你調查兩種方式:

  1. 事件處理程序不點火,這通常發生在動態創建的內容。要修復它,請向父級添加事件偵聽器。

  2. 確保創建要替換的動態內容時,沒有使用相同的ID重複,因爲事件處理程序將只在第一ID找到在HTML樹

UPDATE火: 我仔細看看你的代碼,我會指出兩件我認爲很奇怪的事情,給你帶來麻煩。

我建議你從$(document).delegate()

//I think this condition is always true on return or refresh and kills your flow 
$('.ui-page').not('.ui-page-active').remove(); 

if (recarga) { 
    location.reload(); 
    recarga=false; 
}; 

刪除也動$(document).delegate()功能後$(document).ready()

+0

我正在尋找應用程序,並且問題是它不加載函數正常。 所以,我不能執行不存在的函數。 – QuemaGalletas