搜索按钮适用于模拟器,但不适用于设备 - jQTouch 和 PhoneGap

发布于 2024-10-22 08:30:46 字数 1837 浏览 2 评论 0原文

我已经在 iPhone 应用程序中设置了基本搜索功能。它的工作原理是 它应该在模拟器上,但是当在设备上使用该应用程序时, 点击搜索按钮时不会执行任何操作。我已经尝试过 有很多事情可以让它发挥作用(onsubmit等),但没有任何效果。 有人可以帮忙吗?

这是我的搜索功能和形式:

function recipeInfo(name, ingredients, url) {   
this.name = name;  
this.ingredients = ingredients;
this.url = url;
}

var vIngredients = new Array();
vIngredients[0] = new recipeInfo("Ackee Pasta", "ackee", "ackpast.html");
vIngredients[1] = new recipeInfo("Ackee and Saltfish", "ackee saltfish", "acksalt.html");
vIngredients[2] = new recipeInfo("Jerk Chicken", "jerk", "jerkchick.html");

// do the lookup
function getData(form) {
    // make a copy of the text box contents
    var inputText = form.Input.value
    var list = $("#search-results");
    list.empty();
    // loop through all entries of vIngredients array
    for (var i = 0; i < vIngredients.length; i++) {
        // compare results
        if (vIngredients[i].ingredients.indexOf(inputText) != -1) {
        var found = true;
        console.log(vIngredients[i].name);
        //add to the list the search result plus list item tags
        list.append (
        $("<li class='arrow'><a href='#' >" + vIngredients[i].name + "</a></li>" )
        );
        }
    }
}
</script>

<form id="search" action="" onsubmit="getData(this.form);">
    <ul class="rounded">
        <li><input type="search" name="Input" placeholder="Search..." onkeydown="if (event.keyCode == 13) getData(this.form)"></li>
    </ul>
    <ul class="edgetoedge" id="results">
        <li class="sep">Results</li>
    </ul>
        <ul class="edgetoedge" id="search-results">
    </ul>
</form>

我应该提到,它在模拟器上工作的唯一原因是: onkeydown="if (event.keyCode == 13) getData(this.form)" 删除它会使其停止在模拟器中工作。

I've setup a basic search function within my iPhone app. It works as
it should on the simulator but when using the app on the device, the
search button doesn't do anything when it is tapped. I have tried
numerous things to get it to work (onsubmit, etc.) but nothing works.
Can anybody help?

Here is my search function and the form:

function recipeInfo(name, ingredients, url) {   
this.name = name;  
this.ingredients = ingredients;
this.url = url;
}

var vIngredients = new Array();
vIngredients[0] = new recipeInfo("Ackee Pasta", "ackee", "ackpast.html");
vIngredients[1] = new recipeInfo("Ackee and Saltfish", "ackee saltfish", "acksalt.html");
vIngredients[2] = new recipeInfo("Jerk Chicken", "jerk", "jerkchick.html");

// do the lookup
function getData(form) {
    // make a copy of the text box contents
    var inputText = form.Input.value
    var list = $("#search-results");
    list.empty();
    // loop through all entries of vIngredients array
    for (var i = 0; i < vIngredients.length; i++) {
        // compare results
        if (vIngredients[i].ingredients.indexOf(inputText) != -1) {
        var found = true;
        console.log(vIngredients[i].name);
        //add to the list the search result plus list item tags
        list.append (
        $("<li class='arrow'><a href='#' >" + vIngredients[i].name + "</a></li>" )
        );
        }
    }
}
</script>

<form id="search" action="" onsubmit="getData(this.form);">
    <ul class="rounded">
        <li><input type="search" name="Input" placeholder="Search..." onkeydown="if (event.keyCode == 13) getData(this.form)"></li>
    </ul>
    <ul class="edgetoedge" id="results">
        <li class="sep">Results</li>
    </ul>
        <ul class="edgetoedge" id="search-results">
    </ul>
</form>

I should mention, the only reason it works on the simulator is because of:
onkeydown="if (event.keyCode == 13) getData(this.form)"
Removing that will make it stop working in simulator.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

楠木可依 2024-10-29 08:30:46

苹果在 iOS 4.2 中“修复”了这个问题。对于要获取 onsubmit 事件的表单,必须有一个 type="submit" 的输​​入标记。

Apple "fixed" this in iOS 4.2. For a form to get onsubmit events, there has to be an input tag with type="submit".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文