onClick event on image

3 views
Skip to first unread message

or9...@gmail.com

unread,
Aug 27, 2015, 9:44:22 AM8/27/15
to JavaScript Templates Engine PURE
Hi,

I'm trying to create click events for each image.

This is my directive, any idea?


var directive = {
        'div': {
            'doc<-docs': {
                'h1': 'doc.name',
                'img.logImg@src': function() {
                    return getUrl(this.url);
                },
                'img.treeViewIcon@onclick': function() {
                      return alert(this.name);
                },
            }
        }
    };

Thanks,
Or.

Mic (BeeBole)

unread,
Aug 27, 2015, 11:45:46 AM8/27/15
to JavaScript Templates Engine PURE
When you inspect the result.
Do you see something like <img class="treeViewIcon" onclick=... /> ?

Try to make an example HTML + JS in a gist, like this https://gist.github.com/beebole/09f33882cce942943157
It is easier to find why something goes wrong.

Mic (BeeBole)

unread,
Aug 27, 2015, 2:21:15 PM8/27/15
to JavaScript Templates Engine PURE
Sorry... I did not understand correctly.

You need to return a string, not a function or a call.

eg:

                'img.treeViewIcon@onclick': function() {
                      return 'alert(' + this.name + ');';
                },
 

On Thursday, 27 August 2015 15:44:22 UTC+2, Or Moushkatel wrote:
Reply all
Reply to author
Forward
0 new messages