0
$("span[data-filter*='restaurants']").find('a').trigger('click'); 

This code is firing on every other browser but Explorer and Edge. It has to be the trigger because I can find the text in the link by changing the trigger to .text. So I know the data-filter aspect is flying. It returns no error in the inspector. I can't find any documentation this shouldn't work!

Here is the actual link. Supposed to filter the portfolio to the 'education' group on click.

jeynon
  • 322
  • 6
  • 16
  • Are you trying to go to the link in the `a` or run a jQuery click handler? – Barmar Jan 17 '18 at 23:28
  • my guess is trying to run a click handler that is connected to the WP plugin. The click drives the filtering of the projects. There is no real link associated with the a. – jeynon Jan 17 '18 at 23:33
  • If the handler is not established with jQuery, I don't think `.trigger()` will run it. – Barmar Jan 17 '18 at 23:45
  • It works cleanly in all other browsers but IE and Edge. I tried to make a onClick handler in my jQuery code and call it with the trigger but it didn't fire that as well. – jeynon Jan 17 '18 at 23:51
  • I can't reproduce the problem with this fiddle: https://jsfiddle.net/barmar/4pf8czqe/ I see the alert in IE 10, IE 11, and Edge 16. – Barmar Jan 17 '18 at 23:57
  • I am wondering if it is caused by the clickable objects being created on dynamically and that trigger not binding. Just as an experiment I ran it on my Facebook link in the upper right and it seems to work. That is not dynamically driven content. – jeynon Jan 17 '18 at 23:59
  • That's certainly possible. See https://stackoverflow.com/questions/203198/event-binding-on-dynamically-created-elements – Barmar Jan 18 '18 at 00:01
  • Although if you didn't bind the handler correctly, clicking on the link manually wouldn't work, either. – Barmar Jan 18 '18 at 00:02

0 Answers0