无法在Cordova iOS应用程序中添加自动完成功能

时间:2017-10-24 06:27:24

标签: javascript android jquery ios cordova

这是我在android cordova项目中执行自动完成文本框的html代码,但它现在正在工作的地方工作

    <!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文件中相同的代码,小提琴正在按预期工作,但是cordova应用程序没有。

附上此问题的屏幕截图以使其更清晰 Refer this screenshot for the Cordova iOS

1 个答案:

答案 0 :(得分: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>