gpt4 book ai didi

jquery - mobile_fu 通过 AJAX 渲染所以看起来

转载 作者:行者123 更新时间:2023-12-01 08:28:50 25 4
gpt4 key购买 nike

我的 Controller 呈现常规 html、mobile_fu 和 javascript,如下所示:

respond_to do |format|
format.html {
render :action => "full", :layout => "application" and return
}
format.mobile {
render :action => "full", :layout => "application" and return
}
format.js {
render :partial => "content", :layout => false and return
}
end

常规 html 渲染效果很好,在网站的 html 版本中使用 AJAX 效果很好,但在移动浏览器上使用 AJAX 似乎总是渲染 format.mobile block 。我在将其绑定(bind)到按钮的单击事件时使用 jQuery,并且我在 iPhone 上的测试总是最终渲染上面的 format.mobile block 。

$.ajax({
beforeSend : function(request) { request.setRequestHeader("Accept", "text/javascript"); },
success : function(response) {
$("#content").append(response);
},
type : 'GET',
url : url, //set somewhere else
data : data //set somewhere else
});

是 jQuery 没有捕获点击事件(iPhone 的怪癖吗?)还是 mobile_fu 负责并且在这里有点霸道?有人已经解决了这个问题或者看看我缺少什么吗?

最佳答案

查看 the code for mobile_fu 显示任何传入的移动请求都将设置为移动。将第 73 行更改为类似这样的内容可能会起作用:

if is_mobile_device? && !request.xhr?

关于jquery - mobile_fu 通过 AJAX 渲染所以看起来,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1322455/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com