Closed ryanbagwell closed 11 years ago
Thanks Ryan!
I feel like having the name be used automatically by default might be a little surprising and hard to undo but the wrapperClass
option sounds good.
This also makes me wonder if we should add a method for getting the wrapper element itself. Like .icbiaControl('wrapper')
or .icbiaControl('getWrapper')
.
The only downside I see to adding a "wrapperClass" option is that you'd have to call the plugin once for each element. So if I have three select elements, I can't just say $('select').icbiaControl({ wrapperClass:'foo'})
, because foo will get applied to each wrapper. If it took a function as an argument, you could presumably check the select element's name attribute and create a new css class based on that attribute.
Or maybe it would be even better to add a general after setup callback function to modify it in other ways too.
Hm. If we add that function for getting the wrapper, you could do this:
$('select').icbiaControl().each(function (i, el) {
var $el = $(el);
$el.icbiaControl('getWrapper').addClass('whatever-' + $el.attr('name'));
});
Oh, another option would be to let wrapperClass
be a function:
$('select').icbiaControl
wrapperClass: (el) -> "whatever-#{ $(el).attr 'name' }"
you beat me to it.
On Fri, Jul 26, 2013 at 11:35 AM, Matthew Tretter notifications@github.comwrote:
Oh, another option would be to let wrapperClass be a function:
$('select').icbiaControl wrapperClass: (el) -> "whatever-#{ $(el).attr 'name' }"
— Reply to this email directly or view it on GitHubhttps://github.com/matthewwithanm/jquery-icbiacontrol/pull/6#issuecomment-21632309 .
Ryan Bagwell 5219 Shorecrest Drive Middleton, WI 53562 (608) 466-6195 (v)
Actually, that's what I was trying to say originally - allow that
wrapperClass
option to be a function or a string.
On Fri, Jul 26, 2013 at 11:35 AM, Ryan Bagwell ryan@ryanbagwell.com wrote:
you beat me to it.
On Fri, Jul 26, 2013 at 11:35 AM, Matthew Tretter < notifications@github.com> wrote:
Oh, another option would be to let wrapperClass be a function:
$('select').icbiaControl wrapperClass: (el) -> "whatever-#{ $(el).attr 'name' }"
— Reply to this email directly or view it on GitHubhttps://github.com/matthewwithanm/jquery-icbiacontrol/pull/6#issuecomment-21632309 .
Ryan Bagwell 5219 Shorecrest Drive Middleton, WI 53562 (608) 466-6195 (v)
Ryan Bagwell 5219 Shorecrest Drive Middleton, WI 53562 (608) 466-6195 (v)
:thumbsup: I like that. I still think we should add a method for getting the wrapper, but this is a nice shortcut for a common case.
Alright, added the wrapperClass
option and pushed it as 1.2.0.
We should document this. I forgot about it!
This is the first time I used this thing. It's pretty baller.
This PR just adds a unique css class to the wrapper so it can be distinguished from others. I had the several select dropdowns in the same form, but wanted a way to target each wrappers.
Not sure if this is the best solution. Perhaps a way to specify a wrapper class name in the options is another way to handle it.