Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
4.44/5 (9 votes)
See more:
Hi Expert,

I am using Obout grid and its already has onmousedown and onclick event registered (this event is inbuilt or by default).

Now I don't want the above event so I have written the following code to stop executing the event and this is working fine if I place the alert inside the stopEventPropagation(e) function, else does not work.

Here is the code that I have written:
C#
<script language="javascript" type="text/javascript">
        function stopEventPropagation(e) {
            if (!e) { e = window.event; }
            if (!e) { return false; }
            /*
            if i am removing or comment 
alert('bug') 
then the code is not working as aspectated else it is working well.
            */
            alert('bug');
            e.cancelBubble = true;
            e = null;
            if (e.stopPropagation) { e.stopPropagation(); }
        }
        function assignEventsToCheckboxes(oboutGrid) {
            // disable the record selection feature by clicking on the records
            var sRecordsIds = oboutGrid.getRecordsIds();
            var arrRecordsIds = sRecordsIds.split(",");
            for (var i = 0; i < arrRecordsIds.length; i++) {
                var oRecord = document.getElementById(arrRecordsIds[i]);
                oRecord.onmousedown = function (e) { stopEventPropagation(e); };
                oRecord.onclick = function (e) { stopEventPropagation(e); };
            }
        }
    </script>

I call the function assignEventsToCheckboxes on body load.
XML
<body onload="assignEventsToCheckboxes(ogrdWorkOrder);">


Note:- The event was assigned by the third party control and i want to remove this event from control.

Your answer will be appreciated!:thumbsup:
Thanks in advance.
Imdadhusen
Posted
Updated 2-Nov-10 20:58pm
v3
Comments
Sunasara Imdadhusen 7-Oct-10 9:21am    
Note:- if i am removing alert('bug'); then it will work fine else not.
Nathan St 7-Oct-10 11:40am    
Personally, I use JQuery for stuff like that - no point re-inventing the wheel - and it also works in a lot more browsers than your bespoke event handling will :-)
hance_micle 1-Dec-10 6:20am    
nice question
Sunasara Imdadhusen 3-Dec-10 2:06am    
But didn't have nice answer :(

1 solution

Hi, I have faced the same kind of issue recently. It's just timing issue so you need to give some delay. Use setTimeout() in appropriate place in your code. For me it's working. I hope this will resolve your problem too.

BTW sorry for the late reply.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900