【问题标题】:Unable to add autocomplete feature in Cordova iOS Application无法在 Cordova iOS 应用程序中添加自动完成功能
【发布时间】:2018-04-04 20:08:53
【问题描述】:

这是我的 html 代码,用于在 android cordova 项目中执行自动完成文本框,但它现在可以在小提琴中工作了

    <!DOCTYPE html>

    <html>
        <head>

            <meta name="format-detection" content="telephone=no">
            <meta name="msapplication-tap-highlight" content="no">
            <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
            <link rel="stylesheet" type="text/css" href="css/index.css">
            <title>Trial App</title>
              <script type="text/javascript" src="js/jquery.js"></script>
           <script type="text/javascript">
    $(document).ready(function() {

      var aTags = ["Krishna", "Shubham", "Sachin", "Android", "Windows", "Himalaya", "Bahubali", "Win", "Game"];

      $("#autocomplete").autocomplete({
        source: aTags
      });


      $('#get_value').on('click', getval);

      function getval() {

        var value_inside = $("#autocomplete").val();
        alert("Value inside text box is: " + value_inside);
      }

    });

  </script>
<body>
<input type='text' title='Tags' id='autocomplete' />
<button id="get_value">get</button>
</body>
</html>

小提琴的链接是:https://jsfiddle.net/krishlahoti/g83x5wLz/

在小提琴中,我使用了与上述 HTML 文件中相同的代码,小提琴按预期工作,但科尔多瓦应用程序没有。

附上一个截图和这个问题,以使其更清楚 Refer this screenshot for the Cordova iOS

【问题讨论】:

  • 可能你忘记了“设备就绪”事件?
  • @Korr $(document).ready(function() 与“设备就绪”相同
  • 不,“设备就绪”对于任何 Cordova/PhoneGap 应用程序都不同且必不可少(查看文档)。 “设备就绪”在 Cordova 完全加载时触发,“文档就绪”在 DOM 完全加载时触发。
  • 但是我在解决方案中提供的代码在没有“设备就绪”的情况下可以正常工作

标签: javascript android jquery ios cordova


【解决方案1】:

经过我同事的大量研究和帮助,我终于可以实现我的目标了。

以下是问题中需要的最终代码:

<!DOCTYPE html>
<html>
<head>

</head>

  <script
              src="https://code.jquery.com/jquery-3.2.1.min.js"
              integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
              crossorigin="anonymous"></script>
  <script
              src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
              integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
              crossorigin="anonymous"></script>
  <script type="text/javascript">
    $(document).ready(function() {

      var aTags = ["Krishna", "Shubham", "Sachin", "Android", "Windows", "Himalaya", "Bahubali", "Win", "Game"];

      $("#autocomplete").autocomplete({
        source: aTags
      });


      $('#get_value').on('click', getval);

      function getval() {

        var value_inside = $("#autocomplete").val();
        alert("Value inside text box is: " + value_inside);
      }

    });

  </script>
<body>
<input type='text' title='Tags' id='autocomplete' />
<button id="get_value">get</button>
</body>
</html>

【讨论】:

    猜你喜欢
    • 2022-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-19
    • 1970-01-01
    • 2014-09-28
    • 1970-01-01
    相关资源
    最近更新 更多