├── gulpfile.js
├── package.json
├── .gitignore
├── submit.php
├── LICENSE
├── README.md
├── vue.ajax-form.js
└── example.html
/gulpfile.js:
--------------------------------------------------------------------------------
1 | /* global require */
2 | var gulp = require('gulp');
3 | var livereload = require('gulp-livereload');
4 |
5 | gulp.task('reload', function() {
6 | gulp.src(['**/*.{php,html}', 'js/*.js'])
7 | .pipe(livereload());
8 | });
9 |
10 | gulp.task('watch', function() {
11 | livereload.listen();
12 | gulp.watch('**/*.{php,html}', ['reload']);
13 | gulp.watch('js/*.js', ['reload']);
14 | });
15 |
16 | gulp.task('default', [], function() {
17 | // fired before 'finished' event
18 | });
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "vue-ajax-form-component",
3 | "version": "1.1.0",
4 | "description": "A component for creating simple AJAX forms.",
5 | "homepage": "http://ohdoylerules.com",
6 | "repository": "https://github.com/james2doyle/vue-ajax-form-component",
7 | "main": "vue.ajax-form.js",
8 | "author": {
9 | "name": "James Doyle",
10 | "email": "james2doyle@gmail.com",
11 | "url": "http://ohdoylerules.com/"
12 | },
13 | "licenses": [{
14 | "type": "MIT",
15 | "url": "http://opensource.org/licenses/MIT"
16 | }],
17 | "dependencies": {},
18 | "devDependencies": {
19 | "gulp": "^3.9.0",
20 | "gulp-livereload": "^3.8.1"
21 | }
22 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #### joe made this: https://goel.io/joe
2 |
3 | #####=== Node ===#####
4 |
5 | # Logs
6 | logs
7 | *.log
8 |
9 | # Runtime data
10 | pids
11 | *.pid
12 | *.seed
13 |
14 | # Directory for instrumented libs generated by jscoverage/JSCover
15 | lib-cov
16 |
17 | # Coverage directory used by tools like istanbul
18 | coverage
19 |
20 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
21 | .grunt
22 |
23 | # node-waf configuration
24 | .lock-wscript
25 |
26 | # Compiled binary addons (http://nodejs.org/api/addons.html)
27 | build/Release
28 |
29 | # Dependency directory
30 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
31 | node_modules
32 |
33 | # Debug log from npm
34 | npm-debug.log
35 |
36 |
--------------------------------------------------------------------------------
/submit.php:
--------------------------------------------------------------------------------
1 | '200 OK',
7 | 400 => '400 Bad Request',
8 | 500 => '500 Internal Server Error'
9 | );
10 | // clear the old headers
11 | header_remove();
12 | // set the header to make sure cache is forced
13 | header("Cache-Control: no-transform,public,max-age=300,s-maxage=900");
14 | // treat this as json
15 | header('Content-Type: application/json');
16 | // ok, validation error, or failure
17 | header('Status: ' . $status[$code]);
18 | // return the encoded json
19 | return json_encode(array(
20 | 'status' => $code < 300, // success or not?
21 | 'data' => $data
22 | ));
23 | }
24 |
25 | // usage
26 | echo json_response(200, [$_POST, $_FILES]);
27 |
28 | exit;
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 James Doyle
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # vue-ajax-form-component
2 |
3 | A [Vue.js](http://vuejs.org/) component for creating simple AJAX forms.
4 |
5 | ### Install
6 |
7 | Available through npm as `vue-ajax-form-component`. Or include as an inline script, like in `example.html`.
8 |
9 | ### Demo
10 |
11 | 
12 |
13 | You can load up the `example.html` file here to test the directive. Just make sure you put this folder in a server that has PHP. Or you can change the `ajax-form` action attribute to point to your API endpoint.
14 |
15 | ### Usage
16 |
17 | Minimal:
18 |
19 | ```html
20 |
{{ response | json }}
52 |