Quantcast
Viewing all articles
Browse latest Browse all 3491

Re : Component, Control or Both

When you define a component, the resulting constructor has a Control property -- there might be some way to make this work on its own.

As a rough test, this snipped seemed to give me a control instance with the same event listeners as the component, when invoked on an already-existing element:
  1. var MyComponent = can.Component.extend({ /* ... */ });
  2. new MyComponent.Control('#foo', {});

I wasn't able to get the scope to work, though: the component had some event listeners for different scope properties, but those bindings were not set up on the control. Passing a 'scope' property in the control's options didn't seem to do anything. I haven't dug into it in any depth, though.

Edit: This is using a recent version of the minor (2.1-pre) branch. I haven't tested any other versions.


Viewing all articles
Browse latest Browse all 3491

Trending Articles