Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.
This repository was archived by the owner on Jun 24, 2020. It is now read-only.

Create jquery_ujs for plgapp similar to rails one #40

@mkasztelnik

Description

@mkasztelnik

Take a look at: https://github.com/rails/jquery-ujs/blob/master/src/rails.js it adds possiblity to define request method type in plain html. E.g. to have working sign out link you can simply create following html:

<a href="/sign_out" data-method="delete">Sign out</a>

This operation also adds CSRF Token to the request.

What is more is can be used to simplify UI creation, e.g. for deleting rimrock jobs:

<a href="/rimrock/jobs/<job_id>" data-method="delete" data-confirm="Are you sure?" data-remote="true">delete</a>

As a conclusion following actions will be performed:

  • ajax:beforeSend event is generated (here some spin icon can be presented to the user)
  • confirmation alert will be shown to the user. Delete action will be performed only when user clicks "OK"
  • ajax query will be triggered with method set to delete
  • ajax:success or ajax:error is generated (in this situation user can e.g. remove html element from the page or show error message)

Here you can see simple usage of mentioned mechanism.

/cc @dharezlak, @mpawlik, @bwilk please let me know what do you think about this feature.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions