• function

jQuery.fn.controls jQuery.fn.controls

 

Get the Controls associated with elements.

jQuery.fn.controls([type])

Parameters

  1. control {String | can.Control}Optional

    The type of Controls to find.

Returns

{can.Control}

The controls associated with the given elements.

When the widget is initialized, the plugin control creates an array of control instance(s) with the DOM element it was initialized on using can.data method.

The controls method allows you to get the control instance(s) for any element.

//- Inits the widgets
$('.widgets:eq(0)').my_box();
$('.widgets:eq(1)').my_clock();

<div class="widgets my_box" />
<div class="widgets my_clock" />

$('.widgets').controls() //-> [ MyBox, MyClock ]

Additionally, you can invoke it passing the name of a control to fetch a specific instance(s).

//- Inits the widgets
$('.widgets:eq(0)').my_box();
$('.widgets:eq(1)').my_clock();

<div class="widgets my_box" />
<div class="widgets my_clock" />

$('.widgets').controls('MyBox') //-> [ MyBox ]