2012-07-17 43 views
0

我有一个FireFox 3.6的问题,不喜欢我在jQuery(v1.7.2)中调用非jQuery函数。FF 3.6和jQuery 1.7和removeEventListener()

砍掉版本的我的代码:

function doInitialiseForm(theField) { 
    /* loop through a few fields and set the appropriate attributes & class */ 
    nX = parseInt(theField) ; 
    var inputElement = '' ; 
    for (i=(nX + 1); i <= 10 ; i++) 
    { 
    $('#acBox' + i).addClass('pHide') ; 
    /* toggle the required attribute/class on the input boxes - for HTML5 input validation to behave correctly ... */ 
    inputElement = document.getElementById('acBoxName_' + i) ; 
    inputElement.removeAttribute('required'); 
    $(inputElement).removeClass('required') 
    } 
} 

$(document).ready(function() { 

    if (isBookingPage == '1') 
    { 
     doInitialiseForm(document.getElementById('AttendingCount')) ; 
    } 
}); 

错误Firefox是报告:

Error: uncaught exception: [Exception... "Not enough arguments" nsresult: "0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)" location: "JS frame :: http//development_server/Booking/js/script.js :: doInitialiseForm:: line 65" data: no] 

这似乎是与FF期待第三个参数removeEventListener()啄,这是可选。但是,我不直接使用removeEventListener()

为了让上面的代码在老版本的FireFox中工作,我需要实现哪些附加代码?

+0

Firefox 3.6的支持截至2012年4月24日,你仍然支持它? – epascarello 2012-07-17 18:38:33

+0

为什么要混合使用DOM和jQuery? '$('#acBoxName_'+ i).removeAttr('required')。removeClass('required');' – epascarello 2012-07-17 18:42:03

+0

对DOM对象的parseInt,这是如何工作的? – epascarello 2012-07-17 18:43:46

回答

0

问题现已解决。

从函数doInitialiseForm()中省略的代码的一部分正在调用setAttribute(),我没有包含第二个参数。

即最初写成

inputElement.setAttribute('required'); 

当它应该是

inputElement.setAttribute('required','');