簡體   English   中英

jquery.validator errorPlacement with jquery.gritter

[英]jquery.validator errorPlacement with jquery.gritter

我正在嘗試在 jQuery.validator 的 errorPlacement 中使用 jQuery.Gritter... 將表單驗證錯誤發送到一個漂亮的小容器。 看起來很簡單。 也許我只是對 OOP 不夠熟悉 .. 呵呵。

    errorPlacement: function(error, element) {          
        $.gritter.add({
            title: 'Whoops!',
            text: error,
            image: '/global/media/formExcl.png',
            sticky: false,
            time: ''
        });
   },

所以......“錯誤”是一個 object......所以這顯然會產生“[object Object]”。 我做了一些搜索,試圖從 object 中找出本質。

我嘗試使用“error.toSource()”來生成 object 的細分。希望獲得包含錯誤值的屬性名稱……但我只是得到了這個……'({0:({}), length :1})'。

'錯誤。['0']'或錯誤。[0] 不適合語法。

幫助一個菜鳥。

error是一個dom元素試試這個。

errorPlacement: function(error, element) {          
        $.gritter.add({
            title: 'Whoops!',
            text: $(error).text(),
            image: '/global/media/formExcl.png',
            sticky: false,
            time: ''
        });
   },

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM