2016-08-11 22:05:23 +08:00
|
|
|
/*
|
2016-08-26 04:26:53 +08:00
|
|
|
* Converts JSON data received from the server to flat array of values.
|
2016-08-11 22:05:23 +08:00
|
|
|
*/
|
2016-08-05 23:00:29 +08:00
|
|
|
function jsonToValuesArray(jsonData) {
|
2016-08-31 23:52:45 +08:00
|
|
|
var errMsgs = [];
|
2016-08-05 23:00:29 +08:00
|
|
|
for (var key in jsonData) {
|
|
|
|
var values = jsonData[key];
|
2016-08-31 23:52:45 +08:00
|
|
|
$.each(values, function (idx, val) {
|
|
|
|
errMsgs.push(val);
|
|
|
|
});
|
2016-08-05 23:00:29 +08:00
|
|
|
}
|
|
|
|
return errMsgs;
|
|
|
|
}
|
2016-08-26 04:26:53 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Calls callback function on AJAX success (because built-in functions don't
|
|
|
|
* work!)
|
|
|
|
*/
|
|
|
|
$.fn.onAjaxComplete = function (cb) {
|
2016-08-31 23:52:45 +08:00
|
|
|
$(this)
|
|
|
|
.on('ajax:success', function () {
|
|
|
|
cb();
|
|
|
|
})
|
|
|
|
.on('ajax:error', function () {
|
|
|
|
cb();
|
|
|
|
});
|
2016-08-26 04:26:53 +08:00
|
|
|
}
|