The SharePoint ribbon shows dynamic tabs/buttons depending on the user's permissions and the selected web part.
In the example below the ribbon's initial tab is set depending if the user has edit permissions or not:
Initial State with Read rights | Initial State with Edit rights |
---|---|
If the user activates a webpart, a set of tabs are added to the ribbon:
This behavior is triggered by a click inside a web part. An inspection of the markup revealed the event handler is set up at the cell level of the webpart table:
By clearing the event handlers we prevent the WpClick function from running.
//jQuery selector : all cells in all webparts var webpartCells = $('td[id*="WebPart"]'); // Clear event handlers webpartCells.attr('onmouseup','');
The approach taken here to clear the event handlers might seem a bit outdated, jQuery has an unbind method that may be a better option.