I have a layer with html like this. Is there a way to dynamically use a query selector to select the span element and add a click event to it?
layer = new Layer html: 'This text is <span class="myStyle">Styled</span>'
Yes, it's possible to use jQuery with Framer, though the two libraries tend to step on eachother's toes. The simplest way I've found is by bringing in jQuery as an npm module (see the documentation for how to do this), then doing something like the code below. Just entering the code alone won't do anything - you'll need to create the module first.
Thanks Steve Ruiz! That's helpful. Is it possible to add an onclick event listener that's a Coffeescript function?
surprisingly... yes. I always thought that the layer would accept and absorb the click event, but by turning off ignoreEvents, we can receive our jquery click events.
That's brilliant, thank you!
just FYI you can do most things with vanilla JS these days, no need to mess with jquery: http://youmightnotneedjquery.com/