標籤:
項目需要,一個頁面上就同時使用了jquery.datepicker、jquery.validate、jquery.uploadify,結果使用中就發現uploadify和datepicker和validate各種衝突,報錯都是js缺少對象。查了好久終於找到瞭解決原因
jquery檔案要修改此處,增加了紅字部分
/** * Determines whether an object can have data */ jQuery.acceptData = function (elem) { var noData = jQuery.noData[(elem.nodeName + " ").toLowerCase()], nodeType = +elem.nodeType || 1; // Do not set data on non-element DOM nodes because it will not be cleared (#8335). return nodeType !== 1 && nodeType !== 9 ? false : // Nodes accept data unless otherwise specified; rejection can be conditional !noData || noData !== true && elem.getAttribute != null && elem.getAttribute("classid") === noData; };
jquery.validate要將下面的代碼注釋掉:
$( this.currentForm ) .validateDelegate( ":text, [type=‘password‘], [type=‘file‘], select, textarea, " + "[type=‘number‘], [type=‘search‘] ,[type=‘tel‘], [type=‘url‘], " + "[type=‘email‘], [type=‘datetime‘], [type=‘date‘], [type=‘month‘], " + "[type=‘week‘], [type=‘time‘], [type=‘datetime-local‘], " + "[type=‘range‘], [type=‘color‘], [type=‘radio‘], [type=‘checkbox‘]", "focusin focusout keyup", delegate) // Support: Chrome, oldIE // "select" is provided as event.target when clicking a option .validateDelegate("select, option, [type=‘radio‘], [type=‘checkbox‘]", "click", delegate);
就解決了。
至於去掉後到底有多少影響,還在測試,不過目前項目運行了2個多月沒有發現有什麼問題,至於什麼原理也沒搞清楚,查了好多資料也沒找到問題所在,只說uploadify很蛋疼~
參考連結 http://blog.csdn.net/dyllove98/article/details/42871203
jquery.datepicker、jquery.validate、jquery.uploadify衝突解決