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
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#