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

feat: add shoelace-plugin #147

Merged
merged 4 commits into from
Oct 16, 2021
Merged

feat: add shoelace-plugin #147

merged 4 commits into from
Oct 16, 2021

Conversation

KonnorRogers
Copy link
Owner

Status

Ready

Additional Notes

  • Adds a shoelace plugin for automatically submitting Shoelace forms over AJAX.
  • Adds notes about ViewHelpers by @yuki24

@netlify
Copy link

netlify bot commented Oct 16, 2021

✔️ Deploy Preview for mrujs canceled.

🔨 Explore the source changes: d85d86c

🔍 Inspect the deploy log: https://app.netlify.com/sites/mrujs/deploys/616adf348c83a10007a558b0

@KonnorRogers KonnorRogers merged commit 5222887 into main Oct 16, 2021
@KonnorRogers KonnorRogers deleted the feat/add-shoelace-plugin branch October 16, 2021 14:31
@rickychilcott
Copy link
Contributor

@ParamagicDev from my read of this -- I don't believe it would allow input form submissions as you've been working on with #145. I also have been using shoelace in my own app and in one case I have a <sl-switch> that does a submit right now with a custom stimulus controller.

By my read, this Shoelace plugin could also find a way to append sl-change events (and possibly others) to the hard-coded list in https://github.com/ParamagicDev/mrujs/blob/main/src/method.ts#L76-L94

@KonnorRogers
Copy link
Owner Author

KonnorRogers commented Oct 16, 2021

Hmmm....this isnt a bad idea. This plugin just came since it was code I had sitting around on a side project. Yes it is possible. It would roughly look like this:

import mrujs from "mrujs"

const methodPlugin = mrujs.corePlugins.find((plugin) => plugin.name === "Method")
methodPlugin.queries.push({ event: "sl-change", selectors: ["sl-switch"] })
mrujs.start()

You could even append an additional callback to check for sl-change as well.

@KonnorRogers
Copy link
Owner Author

I have largely left this undocumented as I still am feeling out how to best do this, but since all core plugins are just objects, they can be changed by finding the plugin and then changing the object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants