开发者

Need some ideas on creative DOM grabbing for a confirmation box

What this little script does is it creates a context menu (right click) that has two options, delete and edit. Ideally it would just ask to confirm to delete, because it is not the end of the world if you accidentally get taken to the modify screen. But in either case, I would like to create some kind of unique message to each situation to display to the user.

$("#myDiv").contextMenu({

  menu: 'myMenu'

},

  function(action, el, pos) {    
  var yesno = confirm(    
  'Are you sure?'
   //you would like to delete? 
   //you would like to edit

);
  if (yesno == true) { 
    window.location(action);
  }

});

<div id="myDiv">

   Right click for options.

</div>

<ul id="myMenu" class="contextMenu">

  <li class="edit">   <a href="some/edit/page">   Edit   </a></li>
  <li class="delete"> <a href="some/delete/page"> Delete </a></li>开发者_JAVA百科;

</ul>

I am not sure of what the accepted methodology would be in this case to grab some information about the actions, because the last thing I want is to write some super convoluted code when there is an easier way to do it.

This code seems moderately flexible, so I can add some more divs, or something like that. However, I would like to avoid a tag soup situation.


try using jQuery Alert plugin

http://abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜