Dropdown - dropdown items all operate as 'links' even without a link

Hey all,

Small - strange one.

I am using the dropdown element - and setting a click event onclick of the drop down item. This has worked fine previously, now it seems I cannot avoid the dropdown item click taking me to my root url.

Any ideas to stop this from happening?

What event do you have there? Also, is there anything entered in the href="" attribute?

Hi @Teodor - thanks for the super fast reply!

Nothing in the href="" attribute.

I have dropdown items, they either trigger a Server Connect, or simply trigger a modal. Example below:

<a class="dropdown-item text-body" dmx-on:click="editJobPost.show();editJobPost.data_detailJobPost.select(id)">Edit Job</a>

Where is the <a> tag placed? Is it on some content page / view?

Embarrassingly found the solution (based on your question). None of these had a href="#" which is what they get by default, normally. When I put these back in - it remains on the page and doesn’t redirect.

1 Like

You have a few options to fix this. Either use:

href="javascript:void(0)"

or

href="#"

or use the prevent modifier:

Screenshot_3

1 Like