bubbling and capturing in javascript 1

bubbling and capturing in javascript

// prevent bubbling effect
function DownloadAsset(AssetId, e) {

    if (!e) var e = window.event
    e.cancelBubble = true;
    if (e.stopPropagation) e.stopPropagation();

    // your ajax call
    $.ajax({....})
}

Here is what the above code is Doing:
1. The function DownloadAsset is called when the user clicks on the link.
2. The function checks if the event is a bubbling event.
3. If it is, it cancels the bubbling effect.
4. The ajax call is made.

Similar Posts