Issue #2749Opened April 30, 2020by HansSchouten0 reactions

Disable hyperlink preventDefault()

Question

By default all html anchor elements have their click behaviour disabled (which is very useful of course). However, I would like to make elements editable that requires some javascript behaviour on hyperlinks to still pass through. For example, editing the content of the various panels in a bootstrap tabs navbar: afbeelding

I have found the following code snippets that set the related preventDefault() behaviour: FrameView and ComponentLinkView.

I tried unsetting the registered click events after loading GrapesJS using removeEventListener, but currently without any luck. Are there any suggestions on what I can try to disable this preventDefault() behaviour on specific elements. Or is it an idea to add the preventDefault only on elements with a href that does not start with a # for example?

Answers (1)

HansSchoutenMay 5, 20200 reactions

I solved it for now by adding an additional script to the component to listen for clicks on the li, which triggers directly the tab('show') call on the a.

$(document).find("li.nav-item").click(function() {
    $(this).find('a').tab('show');
})

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.