我需要有关jqueryMobile应用程序的帮助。
http://www.mandinker.com/proyects_vip_dev/app-llarjove/
这是错误:
TypeError:calendario不是函数
...“。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);
}
任何的想法?
据我所知,您的POST请求仅在您第一次单击“ CALENDARIO”时才执行。我建议您研究两种可能性:
您的事件处理程序未触发,这通常发生在动态创建的内容上。要解决此问题,请向父级添加一个事件侦听器。
确保在创建动态内容时要替换的内容,而不是使用相同的ID进行复制,因为事件处理程序只会在HTML树中找到的第一个ID上触发
更新:我对您的代码进行了很好的介绍,我将指出两件我认为很奇怪并给您带来麻烦的事情。
我建议你从 $(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()
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句