Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data-remote links that enter the DOM after page load act as normal links #42

Closed
existentialmutt opened this issue Jun 12, 2021 · 2 comments · Fixed by #47
Closed

data-remote links that enter the DOM after page load act as normal links #42

existentialmutt opened this issue Jun 12, 2021 · 2 comments · Fixed by #47
Labels
Priority: High Status: Unresolved Type: Bug Something isn't working Type: Feature New feature or request
Milestone

Comments

@existentialmutt
Copy link
Contributor

Expected Behaviour

I should be able to add a data-remote link to the DOM and have it work the same as one that was present at page load.

Actual Behaviour

data-remote links added to the DOM after page load don't submit a fetch request and act like normal links.

Interestingly, remote forms that are added to the DOM after page load still seem to work.

Steps to Reproduce

See https://github.com/existentialmutt/cable_car_messages/tree/mrujs . Start up the app and click on New Message, then "Cancel" .

tested with mrujs-0.3.0-beta.11

@existentialmutt existentialmutt added the Type: Bug Something isn't working label Jun 12, 2021
@KonnorRogers
Copy link
Owner

Ahhh yes! this a known issue! This on the todo-list to get fixed. The temporary workaround is once youve added the data-remote link to the dom, call mrujs.restart() this will re-run all queries.

The real reason this happens is i havent gotten around to MutationObservers for everything! The reason forms still work is because form submit events get intercepted at the document level. With links, theres no document level event to hook into.

TLDR: Im working on it, in the meantime, anytime you add a data-remote link, restart mrujs like so:

window.mrujs.restart()

@existentialmutt
Copy link
Contributor Author

Thanks @ParamagicDev , glad it's a known thing! I confirmed mrujs.restart() does fix it so I'll use that as a workaround for now.

Project Planning automation moved this from To do to Done Jun 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: High Status: Unresolved Type: Bug Something isn't working Type: Feature New feature or request
Projects
Development

Successfully merging a pull request may close this issue.

2 participants