From bd9769f5f9619bc0ade3a43efe66dc1948b08a35 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Thu, 9 Jul 2020 17:28:28 +0800 Subject: [PATCH] update Former-commit-id: 6eb5cc06348e15da4faac962e4ac62b304e73f61 Former-commit-id: e842d7e73d0cff1b97c7e0b4308abb6612cf637f --- projects/WebMVC/wwwroot/js/common.js | 18 +++++++-- .../WebMVC/wwwroot/router/shared/edit.html | 37 +++++++++++++------ .../wwwroot/router/shared/edit/string.html | 11 ++++-- 3 files changed, 48 insertions(+), 18 deletions(-) diff --git a/projects/WebMVC/wwwroot/js/common.js b/projects/WebMVC/wwwroot/js/common.js index dfbd5def..c53f8b39 100644 --- a/projects/WebMVC/wwwroot/js/common.js +++ b/projects/WebMVC/wwwroot/js/common.js @@ -5,7 +5,7 @@ Vue.prototype.uploadUrl = config.uploadUrl; Vue.use(window.vuelidate.default); Vue.directive('valid', { - bind: function (el, binding) { + inserted: function (el, binding) { if (binding.value) { $(el).attr('data-val',true); if (binding.value.required) { @@ -15,11 +15,23 @@ Vue.directive('valid', { $(el).attr('data-val-regex-pattern', binding.value.pattern.regex); $(el).attr('data-val-regex-message', binding.value.pattern.message); } + //var temp = this; + //$(el).change(function () { + // console.log(temp); + // if (!$(this).attr('data-val')) { + // return; + // } + // if (!$(this).attr('data-val-required')) { + // if (!$(this).val()) { + // console.log('required'); + // } + // } + //}); } }, update: function (el, binding) { - if (binding.value !== binding.oldValue) { - console.log('value changed:' + el.value); + if (binding.value.currentValue !== binding.oldValue.currentValue) { + //$(el).parents('form').validate().element($(el)); } } }); diff --git a/projects/WebMVC/wwwroot/router/shared/edit.html b/projects/WebMVC/wwwroot/router/shared/edit.html index c571d306..94339e1f 100644 --- a/projects/WebMVC/wwwroot/router/shared/edit.html +++ b/projects/WebMVC/wwwroot/router/shared/edit.html @@ -3,8 +3,8 @@

{{title}}

-
-
+ +