treeview adding data-mdb-open-on-click=false still activates


Topic: treeview adding data-mdb-open-on-click="false" still activates link

Yiannis Kyriazidis pro premium priority asked a week ago

In treeview when using data-mdb-open-on-click="false"
then clicking on icon with href still activates the link , even though it should'nt

See example below. Click on node Three.

https://mdbootstrap.com/snippets/standard/yiannis_kyriazidis/3476691


Michał Duszak commented a week ago

All this attribute does it prevents treeview from expanding when you click on text. Only icon click expands the list then. What behaviour would be expected after you create an anchor in the treeview?


Yiannis Kyriazidis pro premium priority answered a week ago

It would be closer if we could do the opposite of the demo . So use the attribute but when user clicks in the close/open icon it would cancel the click event and just toggle the treenode. Can this be done in the event handler ? so that the icon click does not trigger the anchor href click event ?


Michał Duszak commented a week ago

I have updated the snippet: https://mdbootstrap.com/snippets/standard/m-duszak/3483391

What about now? Arrow only toggles the treenode. Label text toggles the treenode and opens new URL


Yiannis Kyriazidis pro premium priority answered a week ago

Because when I click on it (the label) I want to call a specific url , just like any other treenode. But I also want to expand it when clicking on the icon.

Think of a documentation system, I have a book that has chapters and each chapter can have pages. When I click on chapter treenode I want to call a url to show a description of the chapter . But I also want to expand a chapter to show the underlying pages in treeview.


Michał Duszak commented a week ago

So you would like to open a link in a new tab on click, and also expand the treeview? I think it would be achievable without attribute we talked about above. Tell me how close was I to the behaviour you expect. Below is my snippet - it has an event listener which is responsible for opening new tabs. So now on click - treenode expands, link is opened in a new tab. Is it the behaviour you wish was happening?

https://mdbootstrap.com/snippets/standard/m-duszak/3481797


Yiannis Kyriazidis pro premium priority commented 7 days ago

Yes this is what i was hoping . Thanks.


Please insert min. 20 characters.
Status

Resolved

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: MDB Standard
  • MDB Version: MDB5 3.10.1
  • Device: windows desktop
  • Browser: chrome
  • OS: windows
  • Provided sample code: No
  • Provided link: Yes
Tags