Skip to content

Commit 0c953d5

Browse files
committed
Fixed importent issue lol
1 parent bc5b42d commit 0c953d5

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,14 @@
1212
Include the CDN in the `head` section of your HTML:
1313
```html
1414
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" defer></script>
15-
<script src="https://cdn.jsdelivr.net/gh/SameeraMurthy/reformjs@latest/dist/reform.js" defer></script>
15+
<script src="https://cdn.jsdelivr.net/gh/SameeraMurthy/reformjs@latest/dist/reform.min.js" defer></script>
1616
```
17+
18+
## Usage
19+
In your HTML:
20+
```html
21+
<form action="/endpoint" method="GET" data-reform="">
22+
<input type="text" name="name" required/>
23+
<button type="submit">Go</button>
24+
</form>
25+
```

dist/reform.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,17 @@
1-
console.log("Hello");
1+
$(document).ready(() => {
2+
$("form[data-reform]").submit(function(e) {
3+
e.preventDefault()
4+
$.ajax({
5+
type: $(this).attr("method"),
6+
url: $(this).attr("action") + "?" + $(this).serialize(),
7+
success: function (response) {
8+
location.href = this.url
9+
},
10+
error: function (xhr, status, err) {
11+
let errorText = `%cPassform Error%c\nStatus Code: %c${xhr.status} ${xhr.statusText}\n%cError: ${err}`
12+
let errorStyle = ["font-weight: bold; color: yellow", "color: orangered", "color: dodgerblue;font-weight: bold;", ""]
13+
console.error(errorText, ...errorStyle)
14+
}
15+
});
16+
})
17+
})

dist/reform.test.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
1-
// window.Reform = {}
2-
// window.Reform.handler = class {
3-
// constructor(element) {
4-
// this.element = element ?? "form[data-passform]"
5-
// }
6-
7-
// handle (element, ) {
8-
9-
// }
10-
// }
11-
121
$(document).ready(() => {
13-
$("form[data-passform]").submit(function(e) {
2+
$("form[data-reform]").submit(function(e) {
143
e.preventDefault()
154
$.ajax({
165
type: $(this).attr("method"),
@@ -27,3 +16,13 @@ $(document).ready(() => {
2716
})
2817
})
2918

19+
// window.Reform = {}
20+
// window.Reform.handler = class {
21+
// constructor(element) {
22+
// this.element = element ?? "form[data-passform]"
23+
// }
24+
25+
// handle (element, ) {
26+
27+
// }
28+
// }

test/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<title>PassformJS Test</title>
88
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js" defer></script>
9-
<script src="../dist/reform.test.js" defer></script>
9+
<script src="../dist/reform.js" defer></script>
1010
</head>
1111
<body>
12-
<form action="./endpoint.htm" method="GET" data-passform="">
12+
<form action="./endpoint.html" method="GET" data-reform="">
1313
<input type="text" name="name" required/>
1414
<button type="submit">Go</button>
1515
</form>

0 commit comments

Comments
 (0)