これが私が抱えている問題です。ドラッグ可能な div にある種のハンドルをアタッチする必要があります。
私がする必要があるのは、親内の div を右クリックするたびにマウスの右ボタンをキャプチャすることです。
これは私の子作成コードです。このコードは正常に動作し、問題なく複数の div を作成できます。
var smallBlock = $('<div class="SmallBlock"></div>').appendTo("#canvas");
smallBlock..draggable({containment: "#canvas", scroll: false, grid: [10, 10]}, {cursor: "move", cursorAt: {top: 125, left: 150}})
smallBlock.append('<div class="article_title fontCenter fontBold font32">Article Title</div>')
smallBlock.append('<div class="article_Image"><img style="width: 250px;" src="<? echo $image1 ?>"></div>')
smallBlock.append('<div class="font14"><? echo substr($article_text, 0, 200) ?></div>')
これがマウスクリックのコードです。
<script type="text/javascript">
function getRightClick()
{
// check for right mouse pressed
$('#canvas').mousedown(function(event) {
switch (event.which) {
case 1:
alert('Left mouse button pressed');
break;
case 2:
alert('Middle mouse button pressed');
break;
case 3:
alert('Right mouse button pressed');
break;
default:
alert('You have a strange mouse');
}
});
}
</script>
右マウスがクリックされたことをdivに認識させる方法がわかりません。
ところで、私が検出する必要がある親内の div の他のクラスがあります。したがって、より一般的なソリューションの方が優れている可能性があります。