function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Shiv ShankarShiv Shankar 

reRendering problem

Hi friends,

 

I have a VF tag like this :

 

<apex:inputtext onkeypress="isEnter(event)" value="{! currentPageNo}" />

 

 

JS like this :

      //To check either Enter key pressed in Page No input text or not.
      function isEnter(event){
          if (event.keyCode == 13){
              jumpOnPage(2);
          }
      }

 Action function is like this :

     <apex:actionFunction name="jumpOnPage" action="{! jumpOnPage}" reRender="mpb">
         <apex:param name="pageNo" value="" assignTo="{! pageNo}"/>
     </apex:actionFunction>

 Problem is : when i am presseing enter the whole page is refreshing not the particular component of page. How to resolve this.

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9

Have a look at this.

 

 

 <apex:inputText value="{!textVal}" onkeypress="return onEnter(event)" />

 Js Function 

 

function onEnter(event){
            if (event.which == 13 || event.keyCode == 13) {             
                //your action function call here
                return false;
            }
            else{
                return true;
            }
        }

 I tried this and is working for me.

All Answers

Avidev9Avidev9
This happens when there are error in your js Code.
Have you tried checking for errors in console ?
Shiv ShankarShiv Shankar
I checked it's not showing any error in console..
Avidev9Avidev9
Then try changing the event to "onkeyup"
Shiv ShankarShiv Shankar
Checked still it's rendering whole page..
Avidev9Avidev9

Have a look at this.

 

 

 <apex:inputText value="{!textVal}" onkeypress="return onEnter(event)" />

 Js Function 

 

function onEnter(event){
            if (event.which == 13 || event.keyCode == 13) {             
                //your action function call here
                return false;
            }
            else{
                return true;
            }
        }

 I tried this and is working for me.

This was selected as the best answer
Shiv ShankarShiv Shankar
Thanks dear it's working perfectly, can i know what mistake i was doing... ? the fundametal which i have learned i applied them .. where i went wrong ?