Skip to content

Commit

Permalink
uri-encodeプロパティ追加
Browse files Browse the repository at this point in the history
  • Loading branch information
hosokawat committed Sep 17, 2019
1 parent 294cf94 commit 808c4ac
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/components/VAjaxForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
module.exports = {
props: {
action: String,
method: String
method: String,
uriEncode: Boolean
}, methods: {
request: function (params) {
const vm = this;
Expand All @@ -23,13 +24,18 @@ module.exports = {
});
}, submit: function () {
let params = {};
this.$el.querySelectorAll('input,select,textarea').forEach(function(el){
let vm = this;
vm.$el.querySelectorAll('input,select,textarea').forEach(function(el){
if ((typeof el.attributes['disabled'] === 'undefined')
&& (typeof el.attributes['name'] != 'undefined')
) {
if ((el.type === 'radio' || el.type === 'checkbox') && !el.checked) return;
let val = el.value;
let name = el.attributes['name'].value;
if(vm.uriEncode) {
val = encodeURIComponent(val);
name = encodeURIComponent(name);
}
if (typeof params[name] === 'undefined') {
params[name] = val;
} else if (params[name] instanceof Array) {
Expand All @@ -39,7 +45,7 @@ module.exports = {
}
}
});
this.request(params);
vm.request(params);
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions v-ajax-form.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion v-ajax-form.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 808c4ac

Please sign in to comment.