question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CommandButton: on click event added manually in JS doesn't work in PF 12

See original GitHub issue

Describe the bug

I put below two problems in one issue, because I think that they may be connected.

  1. In CommandButton on click event added manually in JS doesn’t work. Problem doesn’t exist in PF 11. I reproduced it in PF 12.0.0-RC2.

I have code:

<script>
jQuery(document).on('click', 'button', function() {
    alert('test');
});
</script>
<h:form>
    <p:commandButton action="back" value="Back" />
</h:form>
  1. What’s more - I don’t have enabled option disableOnAjax="true" nor inlineAjaxStatus="true" (added in PF 12 #8301), but when I run below code
<script>
    window.onbeforeunload = function() {
        return "Your data will be lost.";
    };
</script>
<h:form>
    <p:commandButton action="back" value="Back" />
</h:form>

My button changes from:

image

to

image

I don’t want this spinner/loading to show on my button when I don’t add any of the option from #8301.

Reproducer

No response

Expected behavior

No response

PrimeFaces edition

Community

PrimeFaces version

12.0.0-RC2

Theme

No response

JSF implementation

Mojarra

JSF version

2.2

Browser(s)

Chrome 103

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

0reactions
jepsarcommented, Aug 5, 2022

It seems impossible due to the disabled state. Some tests:

<script>
    jQuery(document).on('click', 'button', function () {
        alert('test');
    });
</script>
<p:commandButton action="back" value="Back" disableOnAjax="false" />
<button>Test</button>
<button onclick="this.disabled=true">Test</button>
<button onclick="this.disabled=true;$(this).trigger('click')">Test</button>
<button onclick="$(this).trigger('click');this.disabled=true">Test</button>
Read more comments on GitHub >

github_iconTop Results From Across the Web

commandButton/commandLink/ajax action/listener method not ...
Introduction. Whenever an UICommand component ( <h:commandXxx> , <p:commandXxx> , etc) fails to invoke the associated action method, or an UIInput component ...
Read more >
CommandButton: add inline Ajax status indicator #8301 - GitHub
CommandButton : on click event added manually in JS doesn't work in PF ... inline progress-indicator when execution action using PF 12 #9296....
Read more >
Command button won't call javascript - Salesforce Developers
Hi All,. I'm having a problem with my visual force page whereby i'm simply trying to get a command button to call a...
Read more >
USER GUIDE 6.2 - PrimeFaces
PrimeFaces is an open source JSF component suite with various extensions. • Rich set of components (HtmlEditor, Dialog, AutoComplete, Charts and many more)....
Read more >
Apex Tutorials - Salesforce coding lessons for the 99%
Calling Apex from a button; Scheduling Apex jobs in a batch ... and the lamest javascript framework ever (Lightning), is NOT a real...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found