1
votes

I've made a composite component which is rendered by function:

$(document).ready(function() {
   ...
}

When I load the page at the beginning everything works fine, but when I added attribute rendered="true|false" and want to switch this component on and off it makes me troubles, because $(document).ready(function() doesn't invoke.

How can I detect from the composite component itself that it's being reloaded and rendered attribute is set to true (last one I believe should be something like #{cc.rendered}

Thank you in advance.

1

1 Answers

1
votes

Add an inline <script> (or <h:outputScript>) to bottom of the conditionally rendered part of the composite which should execute the desired function.

<cc:implementation>
    <ui:fragment rendered="#{someCondition}">
        ...
        <script>someFunction();</script>
    </ui:fragment>
</cc:implementation>

That function can in turn delegate to $(document).ready(), if necessary.