A4j: onkeyup support event does not work with right click copy and paste

I tried to find a list of all possible events that can be used in the a4j: support event attribute. I can’t find the link that lists them, maybe someone can provide the link? I know about obvious ones like onclick, onchange, etc.

The reason I'm asking about this is because I have an input text box. It has an onkeyup event attached to it via the a4j: support tag. It should include a text field when an event fires. The event does not fire when the user right-clicks and inserts content into the field. Is there an alternative event that I could use to provide control of this case?

<h:inputText id="someName" value="#{myBean.example.exampleName}" maxlength="25" style="width:280px">
    <a4j:support event="onchange" reRender="exampleTab" 
        action="#{myBean.activateTabPanel}" ajaxSingle="true" 
        ignoreDupResponses="true" />
</h:inputText>

<rich:tabPanel id="exampleTab" switchType="server"
    style="width:100%;height:448px;" styleClass="top_tab"
    inactiveTabClass="inactive_tab" activeTabClass="active_tab"
    selectedTab="#{myBean.exampleTabState.selectedTab}">
    <!-- Various stuff in here --->
</rich>


**** *****


, jQuery. . .

jQuery(document).ready(function() {

    // Call contructor
    var common = new Site.Common();

});


// Constructor
Site.Common = function() {

    // Only attach event listener if the element exists on page
    if ( jQuery('input[id$="suggest"]') ) {
        jQuery('input[id$="suggest"]').bind('paste', Site.Common.handleMousePaste.bind(this));
    }

};


// Trigger the keyup event when user uses mouse to paste content info a field('element')
Site.Common.handleMousePaste = function(event) {

    // Need to split the id (JSF adds the form name in front of the input field!)
    var idParts = event.target.id.split(':');

    // Reformat the id we will pass to jQuery (It does not understand formName:fieldName, need to escape the ':')
    if (idParts.length >= 2) {
        var formattedID = "#" + idParts[0] + "\\:" + idParts[1];
    }
    else {
        var formattedID = "#" + event.target.id;
    }

    // Need to put a tiny delay in so the element has time to get the pasted in content.
    setTimeout(function() { jQuery(formattedID).keyup(); }, 10);

};

+3
3

js .

,

,

if (event.ctrlKey && event.keyCode == 86) //Paste event
   call your function
+1

(, ..). , OnChange, OnChange , , , .

OnInput HTML5. OnInput , . , , ..

, : IE9, IE10, IE11, Chrome, Firefox, Safari Opera.

+1

event , :

JavaScript (onclick, onchange ..) , AJAX

, event, onXXX, .


, <a4j:support event="onkeyup"> <a4j:support event="onchange">.

Please note that if your request is intended only to include a text field, perhaps you can do it using JavaScript, rather than using an Ajax call (i.e. using <a4j:support>).

0
source

Source: https://habr.com/ru/post/1789793/


All Articles