javascript - jQuery - using JS events like "dragover" -


i've got javascript function eventlistener `dragover.

it looks this:

    document.getelementbyid("someid").addeventlistener("dragover",         function(){              //do logic         },       false); 

the thing - someid dynamic element - gets removed , added on page. after it's removed , added in, eventlistener no longer pickup dragover event. way know of how deal situation use jquery's .on()

my problem: can't find dragover event under jquery api... exist? if not how can use in jquery?

you can define customer drag event as,

(function(jquery) {  //defining drag event. jquery.fn.drag = function() {     eventtype = arguments[0] || 'dragstart';     onevent = typeof arguments[1] == 'function' ? arguments[1] : function() {     };     eventoption = arguments[2] || false;      $(document).on('mouseover', $(this).selector, function() {         if ($(this).hasclass(eventtype)) {             return;         }         if (! typeof eventtype == 'string') {             return;         }          console.log('binding drag event');         $(this).each(function() {             $(this)[0].addeventlistener(eventtype, onevent, eventoption);             $(this).addclass(eventtype);         })     }); } })(jquery); 

and have add plugin , apply required selector follows.

$('#someid').drag('dragover', function(){          //do logic         alert('dragging!!!!!!');     },   false); 

working fiddle http://jsfiddle.net/sadepu/adyfp/


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -