我在网页上有一个缩略图列表,点击它们后,它会在新屏幕中重定向到相应的游戏。我想添加一个功能,要求用户输入他们的优势手,即点击缩略图时出现的对话框询问“他们的优势手是什么?两个按钮:左和右”。一旦用户选择了任一选项,它就进入游戏。我使用了http://jqueryui.com/dialog/#modal-confirmation和许多其他选项,但它不起作用。
我的代码是:
<li class="show-list" onclick="location.href='/excercises/gameserve?id={$exerData.id}'" id="hand">
所以有一个列表
此外,如果它有帮助,所选选项必须存储在数据库中..
任何人都可以帮忙......
答案 0 :(得分:0)
首先你不能拥有所有li的相同id,所以请将手作为一个不是id的类
然后将html作为
<li class="show-list" data-href="/excercises/gameserve?id={$exerData.id}" class="hand">your desired text</li>
<div id="dialog-confirm" style="display:none" title="Please select your dominent hand?">
<p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Plesae select your dominent hand?</p>
</div>
然后使用jquery
$("li.hand").on("click",function(){
var $self = $(this);
$( "#dialog-confirm" ).dialog({
resizable: false,
height:140,
modal: true,
buttons: {
"Right": function() {
//get the url here
var url = self.attr("data-href");
//post a ajax request using the
},
"Left": function() {
var url = self.attr("data-href") ;
//post a ajax request using the
}
}
});
})