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();
开发者_如何学Go 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>
Found a solution: if I changed it so that the orderlinks trigger jQT.goTo() it worked.
精彩评论