Skip to content

Commit

Permalink
Fixed importent issue lol
Browse files Browse the repository at this point in the history
  • Loading branch information
SameeraMurthy committed Mar 20, 2021
1 parent bc5b42d commit 0c953d5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,14 @@
Include the CDN in the `head` section of your HTML:
```html
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/gh/SameeraMurthy/reformjs@latest/dist/reform.js" defer></script>
<script src="https://cdn.jsdelivr.net/gh/SameeraMurthy/reformjs@latest/dist/reform.min.js" defer></script>
```

## Usage
In your HTML:
```html
<form action="/endpoint" method="GET" data-reform="">
<input type="text" name="name" required/>
<button type="submit">Go</button>
</form>
```
18 changes: 17 additions & 1 deletion dist/reform.js
Original file line number Diff line number Diff line change
@@ -1 +1,17 @@
console.log("Hello");
$(document).ready(() => {
$("form[data-reform]").submit(function(e) {
e.preventDefault()
$.ajax({
type: $(this).attr("method"),
url: $(this).attr("action") + "?" + $(this).serialize(),
success: function (response) {
location.href = this.url
},
error: function (xhr, status, err) {
let errorText = `%cPassform Error%c\nStatus Code: %c${xhr.status} ${xhr.statusText}\n%cError: ${err}`
let errorStyle = ["font-weight: bold; color: yellow", "color: orangered", "color: dodgerblue;font-weight: bold;", ""]
console.error(errorText, ...errorStyle)
}
});
})
})
23 changes: 11 additions & 12 deletions dist/reform.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
// window.Reform = {}
// window.Reform.handler = class {
// constructor(element) {
// this.element = element ?? "form[data-passform]"
// }

// handle (element, ) {

// }
// }

$(document).ready(() => {
$("form[data-passform]").submit(function(e) {
$("form[data-reform]").submit(function(e) {
e.preventDefault()
$.ajax({
type: $(this).attr("method"),
Expand All @@ -27,3 +16,13 @@ $(document).ready(() => {
})
})

// window.Reform = {}
// window.Reform.handler = class {
// constructor(element) {
// this.element = element ?? "form[data-passform]"
// }

// handle (element, ) {

// }
// }
4 changes: 2 additions & 2 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PassformJS Test</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" defer></script>
<script src="../dist/reform.test.js" defer></script>
<script src="../dist/reform.js" defer></script>
</head>
<body>
<form action="./endpoint.htm" method="GET" data-passform="">
<form action="./endpoint.html" method="GET" data-reform="">
<input type="text" name="name" required/>
<button type="submit">Go</button>
</form>
Expand Down

0 comments on commit 0c953d5

Please sign in to comment.