Skip to content
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

plugn should inherit classes on items #4

Open
gcphost opened this issue Mar 15, 2012 · 2 comments
Open

plugn should inherit classes on items #4

gcphost opened this issue Mar 15, 2012 · 2 comments

Comments

@gcphost
Copy link

gcphost commented Mar 15, 2012

adding classes to the items in your select list make it pretty - with this plugin it did not inherit any classess

its one line to inherit classes, and makes the plugin pretty darn good

added this code

            if ($(this).attr("class")) { li.addClass($(this).attr("class")); } 

full code area like this

        this.find("option").each(function() { 
            var li = $("<li>" + $(this).text() + "</li>")
                .data("value", $(this).attr("value"))
                .data("name", $(this).text())
                .appendTo(ul);
            if ($(this).attr("selected")) { li.addClass("selected"); } 
            if ($(this).attr("class")) { li.addClass($(this).attr("class")); } 
        });

works perfect - makes the plugin very nice.

@shawnchin
Copy link
Owner

Thanks. That looks sensible. I'll have a closer look and merge it in when I get back in front of a computer at the end of the month.

On 16 Mar 2012, at 00:55, gcphostreply@reply.github.com wrote:

adding classes to the items in your select list make it pretty - with this plugin it did not inherit any classess

its one line to inherit classes, and makes the plugin pretty darn good

added this code

           if ($(this).attr("class")) { li.addClass($(this).attr("class")); } 

full code area like this

       this.find("option").each(function() { 
           var li = $("<li>" + $(this).text() + "</li>")
               .data("value", $(this).attr("value"))
               .data("name", $(this).text())
               .appendTo(ul);
           if ($(this).attr("selected")) { li.addClass("selected"); } 
           if ($(this).attr("class")) { li.addClass($(this).attr("class")); } 
       });

works perfect - makes the plugin very nice.


Reply to this email directly or view it on GitHub:
#4

@shawnchin
Copy link
Owner

My apologies for taking so long to attend to this.

I agree that it would be nice if it is possible for users to influence the style of the generated <li>, however I'm not sure if inheriting classes from <option> is an approach that would serve well for most use cases. They are after all different element types, and the effort one puts into styling one may not be directly transferrable to the other.

These are some of options I'm considering:

  • provide an option for users to specify additional classes to attach to the generated elements (<ul> and <li>).
  • apply pre-defined classes to the elements and allowing users to define the styles as they see fit.
  • provide an option to enable inheritance of classes from <option> (your suggestion)

I also do some concerns that inheriting styles indiscriminately may break the rows/cols layout of the menu if we're not careful. The above mentioned features, were they to be implemented, should probably not be enable by default to avoid unexpected behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants