From 0c953d5eafe08164ed8451e2902aab43e41e1d1e Mon Sep 17 00:00:00 2001 From: Sameera Murthy Date: Sat, 20 Mar 2021 15:59:48 -0400 Subject: [PATCH] Fixed importent issue lol --- README.md | 11 ++++++++++- dist/reform.js | 18 +++++++++++++++++- dist/reform.test.js | 23 +++++++++++------------ test/index.html | 4 ++-- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index b65fabe..d09eee7 100644 --- a/README.md +++ b/README.md @@ -12,5 +12,14 @@ Include the CDN in the `head` section of your HTML: ```html - + ``` + +## Usage +In your HTML: +```html +
+ + +
+``` \ No newline at end of file diff --git a/dist/reform.js b/dist/reform.js index bf6b817..97ade8e 100644 --- a/dist/reform.js +++ b/dist/reform.js @@ -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) + } + }); + }) +}) \ No newline at end of file diff --git a/dist/reform.test.js b/dist/reform.test.js index 4a89931..b7322bb 100644 --- a/dist/reform.test.js +++ b/dist/reform.test.js @@ -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"), @@ -27,3 +16,13 @@ $(document).ready(() => { }) }) +// window.Reform = {} +// window.Reform.handler = class { +// constructor(element) { +// this.element = element ?? "form[data-passform]" +// } + +// handle (element, ) { + +// } +// } \ No newline at end of file diff --git a/test/index.html b/test/index.html index b63ba66..f1e5a84 100644 --- a/test/index.html +++ b/test/index.html @@ -6,10 +6,10 @@ PassformJS Test - + -
+