2

I need help: How to call Visualforce Component function from another Visualforce Component. Below are Code details. i.e call 'display.component' click function from 'view.component'

1st Component: view.component

<apex:component>
    <script id="View" type="text/template">
        <button type="button" class="btn btn-primary myBtn">Click</button>
    </script>
</apex:component>

2nd Component: display.component

<apex:component>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
    $(document).ready(function(){
        $('.myBtn').click(function () {
            alert("Hello")
        });
    });
</script>
</apex:component>
1

your selector for the click method is wrong.It should look like below

$('.myBtn').click(function () {
      alert("Hello")
       });
});
|improve this answer|||||
  • Hi vppravi93 .I just edited element to class.but is it works because I have to call other component function? – Adi Jul 8 '15 at 6:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.