Handle mouse click on links with SVG graphics
Other day I faced this problem. If you place SVG into a tag, that is observed with javascript, and then click on zone with graphics, listeners are ignored.
So I've found this solution:
$ ->
# Select only links with event bindings. In Rails they have data-method attribute.
$('a[data-method] svg').click (e) ->
e.preventDefault()
e.stopPropagation()
$(this).parent().click()Written by Stanislav Ryahov
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Javascript
Authors
Filed Under
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#