New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String parameter not working as expected for: jQuery.fn.control / jQuery.fn.controls #448

Merged
merged 1 commit into from Oct 11, 2013

Conversation

Projects
None yet
2 participants
@daffl
Contributor

daffl commented Oct 11, 2013

Using CanJS v1.1.6

String parameter not working as expected for: jQuery.fn.control / jQuery.fn.controls

Reference: http://canjs.com/docs/jQuery.fn.control.html

//
//  Define Plugin
//
var MyPlugin = can.Control.extend('MyPlugin', {
  pluginName: 'MyPlugin'
}, {});

// init plugin
$('body').MyPlugin();


//
//  Attempt to get defined plugin
//
$('body').control(); // returns MyPlugin (works as expected)
$('body').control(); // returns MyPlugin (works as expected)
$('body').control(MyPlugin); // returns MyPlugin (works as expected)

$('body').control('MyPlugin');  // returns undefined
$('body').control('myplugin'); // return undefined
@tilleps

This comment has been minimized.

Show comment
Hide comment
@tilleps

tilleps Jul 11, 2013

Turns out that the string parameter will need to be converted with can.underscore()

$('body').control('MyPlugin');  // returns undefined
$('body').control( can.underscore('MyPlugin') ); // returns MyPlugin
$('body').control('my_plugin'); // returns MyPlugin

This does not seem intuitive as initializing the plugin is done with the string defined in pluginName

$('body').MyPlugin();  // initializes
$('body').my_plugin(); // Error: has no method 'my_plugin'

Notes/examples of this behavior would be helpful on the documentation page
http://canjs.com/docs/jQuery.fn.control.html

tilleps commented Jul 11, 2013

Turns out that the string parameter will need to be converted with can.underscore()

$('body').control('MyPlugin');  // returns undefined
$('body').control( can.underscore('MyPlugin') ); // returns MyPlugin
$('body').control('my_plugin'); // returns MyPlugin

This does not seem intuitive as initializing the plugin is done with the string defined in pluginName

$('body').MyPlugin();  // initializes
$('body').my_plugin(); // Error: has no method 'my_plugin'

Notes/examples of this behavior would be helpful on the documentation page
http://canjs.com/docs/jQuery.fn.control.html

@tilleps

This comment has been minimized.

Show comment
Hide comment
@tilleps

tilleps Jul 11, 2013

Another note, the fullName parameter can.Control() must also be provided in order for control() and controls() to match a control.

Would there be any issues assigning pluginName as fullName if fullName is not provided?

//
// Instead of having to manually assign fullName and pluginName
//
var MyPlugin = can.Control.extend('MyPlugin', {
  pluginName: 'MyPlugin'
}, {});

//
// Allow this instead
//
var MyPlugin = can.Control.extend({
  pluginName: 'MyPlugin'
}, {});


MyPlugin.fullName;  // return undefined (currently)
MyPlugin.fullName;  // returns MyPlugin (proposed)

tilleps commented Jul 11, 2013

Another note, the fullName parameter can.Control() must also be provided in order for control() and controls() to match a control.

Would there be any issues assigning pluginName as fullName if fullName is not provided?

//
// Instead of having to manually assign fullName and pluginName
//
var MyPlugin = can.Control.extend('MyPlugin', {
  pluginName: 'MyPlugin'
}, {});

//
// Allow this instead
//
var MyPlugin = can.Control.extend({
  pluginName: 'MyPlugin'
}, {});


MyPlugin.fullName;  // return undefined (currently)
MyPlugin.fullName;  // returns MyPlugin (proposed)
@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jul 11, 2013

Contributor

Thanks! These docs are definitely not up-to date. I will have a look at it today.

Contributor

daffl commented Jul 11, 2013

Thanks! These docs are definitely not up-to date. I will have a look at it today.

@ghost ghost assigned daffl Jul 17, 2013

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Oct 11, 2013

Contributor

This was actually a bug which is fixed now with the attached pull request. Documentation has been updated as well.

Contributor

daffl commented Oct 11, 2013

This was actually a bug which is fixed now with the attached pull request. Documentation has been updated as well.

daffl added a commit that referenced this pull request Oct 11, 2013

Merge pull request #448 from bitovi/control-plugin-naming-448
String parameter not working as expected for: jQuery.fn.control / jQuery.fn.controls

@daffl daffl merged commit 1b4e48c into master Oct 11, 2013

1 check passed

default The Travis CI build passed
Details

@daffl daffl deleted the control-plugin-naming-448 branch Oct 11, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment