jQuery 无法与 iPhone 中的 jQTouch 配合使用
我在 Asp.Net MVC 3 应用程序中使用 jQTouch 作为 Web 应用程序。该应用程序有一个 ID 为 ajax_form 的订单表单,当单击类为“orderlink”的链接时,该表单将填充此链接中的 id 和文本。
当我在桌面浏览器中测试应用程序时,所有这些工作正常。然而,当我在 iPhone 上尝试时,表单可以正常工作,但单击链接时,值不会插入到表单中。那么为什么它在桌面浏览器上可以工作,但在 iPhone 上却不行呢?
这是 jQuery(包括所有内容,以防出现冲突或需要发现的内容,但我指的是 .submit 点击函数和 orderlink 实时点击函数):
<script type="text/javascript">
$(document).ready(function () {
updateDetails();
$(".submit").click(function () {
var form = $("#ajax_form");
var action = "@Url.Action("Order")";
var serializedForm = form.serialize();
$.post(action, serializedForm, function(data) {
$('#orderresult').html(data);
});
return false;
});
$('.orderlink').live('click', function() {
var prodno = this.id; //Why should this not have $(this)? Doesn't work then.
var name = $(this).text();
$("#productnumber").val(prodno);
$("#productname").val(name);
});
$(".back").click(function () {
$('#orderresult').html("");
});
$('#names').change(function() {
updateDetails();
});
$('#features').change(function() {
updateDetails();
});
});
function updateDetails() {
var nameid = $('#names').val();
var featureid = $('#features').val();
var url = "@Url.Action("DatabaseDetails")";
$.get(url, {nameid: nameid, featureid : featureid}, function(data) {
$('#databasedetails').html(data);
});
}
</script>
编辑:
奇怪的是,如果我删除回调 $('#订单结果').html(数据);有时它会起作用。但我看不出为什么它只在某些时候有效的模式。我只需要继续点击链接几次,几次之后,表单就会使用当前单击的链接的新值进行更新......行为非常不稳定。以下是订单链接示例:
<a class="orderlink" id="2" href="#ajax_form">Configurator Software</a>
<a class="orderlink" id="1" href="#ajax_form">ACME Hard Drive 2000</a>
I am using jQTouch for a web app, in an Asp.Net MVC 3 application. The app has an order form with id ajax_form, and when clicking a link with class "orderlink" the form is populated with id and text from this link.
All this works fine when I test the app in a desktop browser. However, when I try it live on the iphone, the form works and all, but the values are not inserted in the form when clicking on the link. So why does it work in the desktop browser but not on the iphone?
Here's the jQuery (including all, in case there's a conflict or something to spot, but it's the .submit click function and orderlink live click function that I'm referring to):
<script type="text/javascript">
$(document).ready(function () {
updateDetails();
$(".submit").click(function () {
var form = $("#ajax_form");
var action = "@Url.Action("Order")";
var serializedForm = form.serialize();
$.post(action, serializedForm, function(data) {
$('#orderresult').html(data);
});
return false;
});
$('.orderlink').live('click', function() {
var prodno = this.id; //Why should this not have $(this)? Doesn't work then.
var name = $(this).text();
$("#productnumber").val(prodno);
$("#productname").val(name);
});
$(".back").click(function () {
$('#orderresult').html("");
});
$('#names').change(function() {
updateDetails();
});
$('#features').change(function() {
updateDetails();
});
});
function updateDetails() {
var nameid = $('#names').val();
var featureid = $('#features').val();
var url = "@Url.Action("DatabaseDetails")";
$.get(url, {nameid: nameid, featureid : featureid}, function(data) {
$('#databasedetails').html(data);
});
}
</script>
EDIT:
Strangely, if I remove the callback $('#orderresult').html(data); it works some of the time. But I can't see a pattern for why it works only some of the time. I just have to keep tapping the links several times and after a few times the form is updated with the new values of the currently clicked link... Very unstable behaviour. Here are example orderlinks:
<a class="orderlink" id="2" href="#ajax_form">Configurator Software</a>
<a class="orderlink" id="1" href="#ajax_form">ACME Hard Drive 2000</a>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到了一个解决方案:如果我更改它以便 orderlinks 触发 jQT.goTo() 它就起作用了。
Found a solution: if I changed it so that the orderlinks trigger jQT.goTo() it worked.