Hey all,

I'm pretty new to Low Pro for jQuery and trying to get things right
first time around

http://www.danwebb.net/2008/1/31/low-pro-for-jquery

I am trying to get multiple instances of low pro behaviors to fire
custom events in other low pro behavior / instances.
I do have a solution that seems to work ok for now, However I wonder
if anyone has a better solution as what I've got seems like it could
be a little more elegant.

Here's my example

...

        <script type="text/javascript">
                $(document).ready(function(){
                                $('#left').attach(LEFT);
                                $('#right').attach(RIGHT, LEFT);
                });
        </script>
....
<p>click me i am the <a href="#" id="left">LEFT event</a></p>
<p>click me i am the <a href="#" id="right">RIGHT event</a></p>

using the following low pro

var LEFT = $.klass({
        initialize: function() {        },
        onclick: function(el) { },
        onTwoleftfeet: function() {
                alert('...but i have 2 left feet.');
        }
});

var RIGHT = $.klass({
        initialize: function(otherBehavior) {
                this.interactionInstance = otherBehavior.instances[0];
        },
        onclick: function(el) {
                alert('First with the right.');
                this.interactionInstance.onTwoleftfeet();
                return false;
        },
});

So it's passing the (already initialised) LEFT behavior into the RIGHT
which then has access to its internal instances array. Obviously we
could scale this by passing in arrays of behaviors, and looping
through instances, but I am questioning the approach in general.
For example the ordering of the "attach" calls is critical, and I sort
of feel there is a lot of work to do to find a partner instance.

Feedback is always appreciated

Reply via email to