Skip to content

Add better support for extended options that UJS has access to  #169

@jho406

Description

@jho406

You can currently expand UJS options by adding custom functionality to application_visit.js with data-sg-replace being your first custom example:

        /**
         * Your first expanded UJS option, `data-sg-replace`
         *
         * This option overrides the `navigationAction` to allow a link click or
         * a form submission to replace history instead of the usual push.
         */
        const navigatonAction = !!dataset?.sgReplace
          ? "replace"
          : meta.navigationAction
        ref.current?.navigateTo(meta.pageKey, {
          action: navigatonAction
        })

You can technically call these using the function version of remote and visit by passing in dataset as an option like this:

remote(“/hello”. {dataset: {sgReplace: true}})

But I'm unsure of the dev experience. I wonder if the right approach is to design for the function first so it looks like

remote(“/hello”. {additionalOptions: {replace: true}})

And also allow for data-sg-replace to work as intended. This story is to investigate what work would be needed to tie the function version and the UJS version together. Or perhaps we should just leave it as is.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions