【问题标题】:Phonegap camera API (iOS) submits FORM?Phonegap相机API(iOS)提交FORM?
【发布时间】:2013-11-09 05:51:48
【问题描述】:

我在表单中放置了一个相机按钮,这样您就可以拍照了,它会将 URI 保存到 localStorage 变量中。问题是每次相机启动时,表单都会在没有我点击提交按钮的情况下提交,因此永远不会存储 URI。我需要它不要触发 submitForm()。有什么见解吗?

哦,该应用正在使用 jquerymobile。

html表单

            <form method="post" onsubmit="return submitForm()" id="myForm" data-ajax="false">
                <lable for="title" class="ui-hidden-accessible">Title</lable><input type="text" name="title" placeholder="Title"><br>
                <button onclick="capturePhoto()">Camera</button><br>
                <input type="text" name="description" placeholder="description">
                <input type="submit" value="submit">
            </form>

js

函数提交表单(){ db.transaction(insertDB, errorCB); $.mobile.changePage("#page2", { reverse: false, transition: "slide" } ); 返回假; }

函数 capturePhoto() { // 使用设备摄像头拍照并将图像检索为 base64 编码字符串 navigator.camera.getPicture(onPhotoDataSuccess, onFail, { quality: 50, destinationType: Camera.DestinationType.FILE_URI }); }

【问题讨论】:

    标签: javascript ios forms jquery-mobile cordova


    【解决方案1】:

    发现问题。我为相机使用了&lt;button&gt; 标签。这将触发 onsubmit 事件。我改用了普通的&lt;a href&gt;,效果很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-01
      • 1970-01-01
      • 2014-06-18
      • 2018-05-27
      相关资源
      最近更新 更多