In sites developed with PHP I often insert in the navbar menu (to be included in the pages) a link to view a Modal present on each page.
Now for a site developed in nodeJS I am trying to do the same by including the link in the navbar menu of the layout page
Unfortunately, however, in this case it does not work
This the code in menu navbar
Hi. What happens when you click on the link?
Also, where is this modal created?
Marzio, you should either use the data-toggle attribute or the dynamic click event. You cannot use both on the same button.
When I click it generates an empty link
The link is in the navbar menu of the layout page which is called from the page containing the modal
It has always worked like this with php
So how is it best to proceed to obtain a good result?
I thought maybe I could put all the modal in the layout page, but I don't know if I'll have any problems later
Your modal, if same on all pages, should actually be in layout page. That is the recommended way of doing it.
On the link, the issue could be that you have href="#" which might be taking you somewhere.
Try href="javascript:void(0)" instead.
Also, as Teodor has pointed, you don’t need data-toggle attribute there. Just the dynamic click event is enough.
If you don’t have the modal on layout page, it can only be access using content.
So something like content.modal_send_email.show() might work. Although, this is not recommended.
Ok I think the most correct solution is to insert the Modal code directly into the layout page, hoping then not to have problems
In this regard, I have long had a doubt.
When the layout page is associated with all the pages of the site, it is possible to transfer all the code and all the settings such as Google Analytics, Scroll-Up, GDPR, … ???
This question is out of scope of current topic. What you are seeking is a better understanding of layout/content pages in NodeJS. There are other posts for this I think.
To me honestly it seemed like a pertinent question, since it is always a layout / page relationship with nodejs code
Anyway, patience, that’s okay
Thanks
