sydcanem / bootstrap-contextmenu

Context menu plugin for Twitter's Bootstrap framework
http://sydcanem.com/bootstrap-contextmenu/
645 stars 193 forks source link

using jquery object as target breaks jquery #54

Closed mafar closed 10 years ago

mafar commented 10 years ago

Hello, Your code should support target option as jquery object because in structured programming sometimes we dont have id`s but we do have reference ot jquery objects and your code stricts user to use either id or class on context-menu div. Restriction is never good.

var target = $('#context-menu');
$('.context').contextmenu({
  target:target , 
 })

It can be fixed by replacing

this.$elements.attr('data-target',this.options.target)

with

this.$elements.data('target',this.options.target)

I pulled above changes and now works flawlessly. Now also accepts jQueryObjects/References as targets in options along-with id or class selector