1

I want to display Popup Window in Edit Mode only, not in Read only.Could you tell me code or Suggestion ?

My Code :

Java script :

function popup(){


  var conf=confirm(" Would you like to copy Service Options of Unit Type")

 if(conf==true){

                document.getElementById("{!$Component.iscopy}").value='true';
            }else{

                document.getElementById("{!$Component.iscopy}").value='false';
            }
        }

 </script>


<apex:commandButton action="{!sasm.selectPage}" value="{!ctrl.caption}"  onclick="popup()" 
                       rerender="frm" disabled="{!NOT(ctrl.isActive)}"

                                status="pagingStatus">                          
                            <apex:param value="{!ctrl.id}" name="pageName"/>
</apex:commandButton>

controller :

public Boolean canBeEdited {
   get { 

if (aprove!=null && aprove.isInApproval)  
              {

                return false;
                }
                else{

            return true;
            }
        }
    }
3
  • Please provide more info, is this on a standard page/ visualforce page? what have you tried so far
    – Rao
    Aug 12, 2014 at 18:52
  • Please see now the code Aug 12, 2014 at 19:05
  • what VF component has id= $Component.iscopy ? and how is that related to the controller? Please add to the posted code. BTW, your controller method can be much simpler: get {return aprove!=null && aprove.isInApproval ? false: true;}
    – cropredy
    Aug 12, 2014 at 20:25

1 Answer 1

0

Its a little difficult to be certain here, due to the small amount of code posted, but if what you want is to only display the popup if the controller property 'canBeEdited' is true, the following will do that:

function popup() {
    if ('true'=='{!canBeEdited}') {
        var conf=confirm(" Would you like to copy Service Options of Unit Type");

        if(conf==true){
                document.getElementById("{!$Component.iscopy}").value='true';
        }else{
                document.getElementById("{!$Component.iscopy}").value='false';
        }
    }
}

Note that this will pull the value of 'canBeEdited' at the time the page was rendered - if you do anything in your page to update that value without regenerating the entire page you may encounter problems.

1
  • You are really great man, love you :) Thanks a lot Aug 14, 2014 at 5:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .