divから文字列値を取得する隠しフィールドがあり、ブラウザで作業しても問題ありませんが、実行時には機能しませんタブレットまたはスマートフォンを使用します。私はこれを取得しません。ここJavaScriptがモバイルデバイス上で動作しない別のフィールドの隠しフィールド値を設定しました
は私のdivと隠しフィールドです:
div id="signature-div" style="border: dotted 2px grey;">
<div id="canvas"></div>
</div>
<input name="signature" type="hidden" id="signature" value="">
と機能:
$(document).ready(function() {
// signature
var W = $("#signature-div").width();
var sigCanvas = $("#canvas").jSignature({width: W, height: 180, "background-color":"#ddd"});
// after signing the offer set hidden field value to signature
$(document).on('mouseup', '#canvas',function(){
//$("form").submit(function() {
var rawSig = $("#canvas").jSignature("getData","svg");
//$("#img").attr("data", 'data:' + rawSig);
//$("#signature").val('data:' + rawSig);
document.getElementById("signature").value = 'data:' + rawSig;
// i have tried both of these up and it doesn't set the hidden value on mobile devices...is there something i'm missing here?
});
});
あなたは 'mouseup' ...錠剤でそれを行うとし、スマートフォンにはマウスがありません。あなたのスクリプトに 'touchend'イベントを追加しようとしてみてください...' $(document).on( 'mouseup touchend'、 '#canvas'、function(){' –
あなたは正しいと思います。それから私はそれを受け入れるでしょう – lewis4u