Problem with get outer instance from xbl component

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with get outer instance from xbl component

pumbosha
I am making my own component and within it I want to set value of outer instance. For example, my main form has:

<xf:model id="fr-form-model">                                                                                   
        <xf:instance id="fr-form-instance">                   
            <form>                                       
                <section-1>     
                    <myControl/>                                     
                </section-1>                               
            </form>                       
        </xf:instance>   
        ....
and inside myControl.xbl I have:

<xf:setvalue model="fr-form-model" ref="instance('fr-form-instance')/form/section-1/myControl" value="'myValue'" /> 
but unfortunately it doesn't see 'fr-form-model' (Reference to non-existing model id: fr-form-model) which is understandable, because component doesn't have to see outer elements, so how can I refer to outer instance ?
Reply | Threaded
Open this post in threaded view
|

Re: Problem with get outer instance from xbl component

Erik Bruchez
Administrator
Do you want to write to the node the component is bound to?

If so, you can write to the control binding with xxf:binding():

    https://gist.github.com/ebruchez/11378574

Otherwise, the quick and dirty way is to use the xxf:instance() function instead. It has visibility through the boundaries of XBL components. But we don't recommend it as it breaks encapsulation.

-Erik
Reply | Threaded
Open this post in threaded view
|

Re: Problem with get outer instance from xbl component

pumbosha
Thank You very much for response. I used xxf:instance() and it worked excellent.

regards,
Tom