vue-formular
Advanced tools
Comparing version 0.0.33 to 0.0.34
@@ -36,2 +36,3 @@ var render_template = require('../../helpers/render-template'); | ||
var that = this; | ||
var value; | ||
@@ -49,4 +50,10 @@ if (this.select2 && typeof $!='undefined') { | ||
.select2(options) | ||
.on("change",function(val){ | ||
that.value = $(this).val(); | ||
.on("change",function(e){ | ||
value = $(this).val(); | ||
if (!value && that.multiple) | ||
value = []; | ||
that.value = value; | ||
}); | ||
@@ -53,0 +60,0 @@ } |
@@ -5,5 +5,7 @@ var merge = require('merge'); | ||
var data = {}; | ||
var value; | ||
this.dirtyFields.forEach(function(field) { | ||
data[field.name] = field.value; | ||
value = getValue(field.value); | ||
data[field.name] = value; | ||
}); | ||
@@ -15,1 +17,27 @@ | ||
} | ||
function isValidMomentObject(value) { | ||
return typeof value=='object' && value.isValid && value.isValid(); | ||
} | ||
function isArray(value) { | ||
return Object.prototype.toString.call( value ) === '[object Array]'; | ||
} | ||
function getValue(value) { | ||
if (typeof value!='object' || isArray(value)) | ||
return value; | ||
if (isValidMomentObject(value)) | ||
return value.format(); | ||
if (typeof value=='object' && value.start && isValidMomentObject(value.start) && value.end && isValidMomentObject(value.end)) { | ||
return { | ||
start: value.start.format(), | ||
end: value.end.format() | ||
}; | ||
} | ||
} |
@@ -11,2 +11,3 @@ module.exports = function() { | ||
var data = this.formData(); | ||
this.$dispatch('vue-formular.sending', data); | ||
@@ -13,0 +14,0 @@ this.status = 'info'; |
{ | ||
"name": "vue-formular", | ||
"description": "a comprehensive vue.js form component", | ||
"version": "0.0.33", | ||
"version": "0.0.34", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "vue", |
@@ -78,3 +78,3 @@ # Vue Formular | ||
uses [daterangepicker](https://github.com/dangrossman/bootstrap-daterangepicker). | ||
the `value` should be passed as a string, matching the 'YYYY-MM-DD' format, or as a moment object. The date will be sent to the server in the following format: `2005-12-11T22:00:00.000Z` | ||
the `value` should be passed as a string, matching the 'YYYY-MM-DD' format, or as a moment object. The date will be sent to the server using `moment`'s [format](http://momentjs.com/docs/#/displaying/format/) method (ISO 8601) | ||
@@ -81,0 +81,0 @@ * `range` `boolean` `optional` pick a range of dates. the `value` prop should be passed as an object with `start` and `end` properties. A similar object is sent to the server |
42780
896