Thread

JS Events available when the Entry Edit list filter is changed?

March 15, 2017 10:52pm

Subscribe [3]
  • #1 / Mar 15, 2017 10:52pm

    litzinger's avatar

    litzinger

    599 posts

    I’m hoping to do something when the filter is changed, thus changing the list of entries displayed. Are there events that I can subscribe to? The JS is compressed, so I can’t really dig into it myself.

  • #2 / Mar 16, 2017 3:14pm

    Kevin Cupp's avatar

    Kevin Cupp

    718 posts

    The last thing we do is a window.history.pushState with the new filtered URL, so maybe you could subscribe to onpopstate? https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onpopstate

  • #3 / Mar 16, 2017 3:34pm

    litzinger's avatar

    litzinger

    599 posts

    ooh, that might work. I’ll give it a go. Thanks!

  • #4 / Mar 16, 2017 4:16pm

    Derek Jones's avatar

    Derek Jones

    7164 posts

    Just an FYI that your Developer Preview downloads include uncompressed JavaScript, to help with debugging.

  • #5 / Mar 16, 2017 9:15pm

    litzinger's avatar

    litzinger

    599 posts

    Note that just calling history.pushState() or history.replaceState() won’t trigger a popstate event. The popstate event is only triggered by doing a browser action such as clicking on the back button (or calling history.back() in JavaScript).

    :(

  • #6 / Mar 16, 2017 9:58pm

    litzinger's avatar

    litzinger

    599 posts

    I was able to use a MutationObserver to detect changes and trigger some code after the filter is changed and new content loaded.

  • #7 / Mar 17, 2017 12:08am

    Kevin Cupp's avatar

    Kevin Cupp

    718 posts

    Sorry, I can’t read! Glad you figured something out.

ExpressionEngine News

#eecms, #events, #releases