Simple link does not work

Hello

In my app.js I have:

var $$ = Dom7;

....

$$('#programapdf').on('click', function(){
   console.log("programapdf");
   app.dialog.alert("programa");
});

And in my index.html:

<a id="programapdf" href="#" class="item-link item-content">Click</a>

Simple, but when I click the link nothing happens
Any help?

1 Like

try it insert event in page init event …

router.js

{
    path: '/your_router/',
    url: './name_file.html', // path file
    options: {
      animate: false, // options
    },
    name: 'name_page',
    on: {
      pageInit: function (event, page){
          // event init 
           
           $$('#programapdf').on('click', function(){
                 console.log("programapdf");
                 app.dialog.alert("programa");
           });

      },
    },
  },

I assume that its a dynamically added item. So, try attaching the event to document like this:

$$(document).on('click', '#programapdf', function(){
   console.log("programapdf");
   app.dialog.alert("programa");
});
2 Likes

This works for me! Thanks

1 Like

I have try this but didn’t work for me.
Thanks

1 Like

Look this:

Thanks! I’ll check it.