2014-03-05 110 views
0

我正在使用PrimeFaces 4.0和tomcat-6。primefaces命令按鈕沒有啓用

我已經使用選項卡視圖編輯配置文件,默認情況下使用jQuery禁用提交按鈕。在改變或按下這些輸入字段時,我使用jQuery再次啓用按鈕。但是,如果我更改輸入文本中的值,該按鈕將被禁用,並且不會再次啓用。

我的方案是編輯一個配置文件,因爲提交按鈕被禁用,直到任何一個領域改變。這些是這些文本字段的ID。

我被

$(function() { 
    jQuery("button[type=submit]").prop("disabled", true).addClass('ui-state-disabled');  
}) 

和禁用按鈕啓用

$(function() { 
$('#productName,#majorVersion,#minorVersion,#buildVersion,#revision,#productDescription') 
     .on('change keypress paste textInput input', 
       function() {PF('submitButton').enable(); 
     }); 
}); 
+0

我的場景是編輯一個配置文件,因爲提交按鈕被禁用,直到任何一個領域改變。這些都是那些文字fields.I的ID的我禁用了$按鈕(函數(){\t \t \t \t \t \t \t \t \t的jQuery( 「按鈕[類型=提交]」)。託( 「已禁用」,真) .addClass( 'UI狀態禁用');} )和ANABLE正在做以下 – esm

+0

$(函數(){$(\t \t \t \t \t \t「#產品名稱,#majorVersion,#minorVersion,#buildVersion, ('change keypress paste textInput input',\t function(){\t \t \t(#'修改,#productDescription')。\t \t jQuery(「button [type = submit]」)。prop(「disabled」,false).addClass('ui-state-disabled'); }); \t \t \t \t \t \t \t \t}); – esm

+0

Dint得到你@想要咖啡 – esm

回答

0

我不知道如果我理解正確的話您的問題! 但正如我所看到的,您在使用PrimeFaces禁用和啓用按鈕時遇到問題。

這裏有一個簡單的例子:

按鈕

<p:commandButton value="THE BUTTON" widgetVar="thebuttonVar"/> 

JS

$(function() {  
    // disables the button on the page load 
    thebuttonVar.disable(); 

    // register the enabling event 
    $('#formId') 
    .on('change keypress paste textInput input', '#productName,#majorVersion,#minorVersion,#buildVersion,#revision,#productDescription', function() { 
     thebuttonVar.enable(); 
     }); 
}); 

同樣,你的代碼將工作,即使你是USI只有變化事件。

+0

嗨哈姆特感謝您的回覆,但它不工作:( – esm

+0

請更新您的問題,一個完整的例子..我的意思是不僅JS還XHTML內容... –