简体   繁体   中英

primefaces command button is not getting enabled

I am using PrimeFaces 4.0 and tomcat-6.

I have used tab view for edit of a profile, by default the submit button is disabled using jQuery. And on change or key press of those input fields I'm enabling the button again using jQuery. But the button is disabled and not getting enabled again if i change the value in the input text.

MY scenario is editing of a profile,in that the submit button is disabled till any one of the field is changed. These are the ID's of those text fields.

I am disabling the button by

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

and to enable

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

I'm not sure if I understood your question correctly! But as I can see that you are having a problem with disabling and enabling a button using PrimeFaces.

Here's a quick example:

Button

<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();
        });
});

Again, your code would be working even if you are using only the change event.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM