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
Ram Shiva KumarRam Shiva Kumar 

Pop up is not coming from VF page

Hi ,

My requirement is to get the pop up when i click on the enter  in VF page. in  the belwo code  controller methos is being  called, but alert  pop up is not coming when i click on the enter. Code  is  below,

VF CODE:
<apex:page controller="bang1">

<script type="text/javascript">
  
  function f1()
  {
  
   alert('Start invoking vf action!');
  
  
  }
 
</script>
  
  <apex:form >
  
  
  <apex:actionFunction name="f1"   action="{!m1}"  />
  
  <apex:commandButton value="enter"  onclick="f1(); return false;"      />
  </apex:form>
  
</apex:page>

Apex:

Public class bang1
{
Public bang1()
{
System.debug('hiiiiiiiiiii');

}

Public void m1()
{

System.debug('hiiiiiiiiiiiiii');




}

}

Regards,
siva.



 
Best Answer chosen by Ram Shiva Kumar
Abhishek_DEOAbhishek_DEO
<apex:actionfunction> also create a JS function on client side(check viewsource) so if you put your custom JS method above to actionfucntion, actionfunction will overwrite your method. 

So to achieve your requirement, you should you actionfunction name to soemthinf else that "f1" and call this in your custom JS.

Suppose your actionfunction name is P1.
<apex:actionFunction name="P1"   action="{!m1}"  />

Now, you can place belwo JS anywhere in page, it will work.

<script type="text/javascript">
  function f1()
  {
   alert('Start invoking vf action!');
   P1();
  }
 
</script>

All Answers

Abhishek_DEOAbhishek_DEO
Put your javascript after the coomandbutton, it would work.
<apex:page controller="bang1">
  <apex:form >
    <apex:actionFunction name="f1"  action="{!m1}"  />
  <apex:commandButton value="enter"  onclick="f1(); return false;"      />
   <script type="text/javascript">
  function f1()
  {
   alert('Start invoking vf action!');
  
  }
</script>
  </apex:form>
</apex:page>
Abhishek_DEOAbhishek_DEO
<apex:actionfunction> also create a JS function on client side(check viewsource) so if you put your custom JS method above to actionfucntion, actionfunction will overwrite your method. 

So to achieve your requirement, you should you actionfunction name to soemthinf else that "f1" and call this in your custom JS.

Suppose your actionfunction name is P1.
<apex:actionFunction name="P1"   action="{!m1}"  />

Now, you can place belwo JS anywhere in page, it will work.

<script type="text/javascript">
  function f1()
  {
   alert('Start invoking vf action!');
   P1();
  }
 
</script>
This was selected as the best answer
Ram Shiva KumarRam Shiva Kumar
Hi Abhishek,

Awesome explanation it worked for me.

Thanks alot