gfranko / jquery.selectBoxIt.js

A jQuery Select Box Plugin for Mobile, Tablet, and Desktop
http://www.selectboxit.com
MIT License
852 stars 301 forks source link

selectBoxIt with jQuery Mobile Themeroller #68

Closed chopperbilly closed 11 years ago

chopperbilly commented 11 years ago

Hi Greg, If I do the following:

newMenu = $("select#menuSelect1").selectBoxIt({theme:"jquerymobile"}).data("selectBoxIt");

the select box appears to have some theming, but it is not the theme I set in the HTML select box code, e.g.:

var selectMenu1 = ''); //////// $('#nameNumberSelect1').selectmenu('refresh'); nameNumSelect = $("select#nameNumberSelect1").selectBoxIt({theme:"jquerymobile"}).data("selectBoxIt"); nameNumSelect.data("selectBoxit").refresh();

What am I doing wrong?

Thanks, Bill. ----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Wednesday, December 19, 2012 9:46 AM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

Awesome! I'm glad I could help out.

In regards to multi-select select boxes, I don't think SelectBoxIt will support them. Adding multi-select support would add considerable complexity, and SelectBoxIt wasn't built for it. If enough people reach out to me asking for multi-select support, then I will consider it, but until then it will not be supported.

— Reply to this email directly or view it on GitHub.

gfranko commented 11 years ago

Here is a jsfiddle that shows how to dynamically create a select box with options, and then how to add an additional option(s) to the select box after it is created. Let me know if you have any questions!

chopperbilly commented 11 years ago

Hi Greg,

unfortunately I get the message "Uncaught type error: Object [object object] has no method 'append' ... at ... line 623 --- see bold test code below below:

Early on in the page: nameNumSelect = $("select#nameNumberSelect1").selectBoxIt({theme:"jquerymobile"}).data("selectBoxIt");

then later when required: . . . setTimeout(function() { nameNumSelect.append($("

I would not need to use the set Timeout in the final code, but just thought I'd do exctly what you show in the jsFiddle.

Your example works OK in Chrome, but I can't get it to work on jQuery Mobile. Remember I am not using the jQuery UI stuff, as your earlier mods to use jQuery Mobile Themeroller obviated that..

Thanks in anticipation, Bill.

----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Thursday, December 20, 2012 4:44 PM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

Here is a jsfiddle that shows how to dynamically create a select box with options, and then how to add additional an additional option(s) to the select box after it is created. Let me know if you have any questions!

— Reply to this email directly or view it on GitHub.

gfranko commented 11 years ago

Hey Billy,

Early on in the page, you should not be adding the data("selectBoxIt") method when you are first calling the selectBoxIt plugin. Instead, do this:

nameNumSelect = $("select#nameNumberSelect1").selectBoxIt({theme:"jquerymobile"});

Your code should no longer complain about the append() method not being there. Let me know if you have any more questions and Merry Christmas =)

Greg

chopperbilly commented 11 years ago

Hi Greg, and Merry Christmas to you also.

I'm off work until the 7th January, so will get back to you (if necessary) when I've done what you say to do.

All the best,

Bill.

On 26 December 2012 14:14, Greg Franko notifications@github.com wrote:

Hey Billy,

Early on in the page, you should not be adding the data("selectBoxIt")method when you are first calling the selectBoxIt plugin. Instead, do this:

nameNumSelect = $("select#nameNumberSelect1").selectBoxIt({theme:"jquerymobile"})

Your code should no longer complain about the append() method not being there. Let me know if you have any more questions and Merry Christmas =)

Greg

— Reply to this email directly or view it on GitHubhttps://github.com/gfranko/jquery.selectBoxIt.js/issues/68#issuecomment-11679419.

chopperbilly commented 11 years ago

Hi Greg, hope you had a merry and safe Christmas and new Year.

Back at work now, not sure if you are though - hope so ....

The fix you gave me to stop the message about the append() method not being there fixed that one. BUT - as soon as i do a refresh, the select box disappears completely - bummer! (Note - if I don't do the refresh, the select box ix still there. but does not have the added options)

Here's my code: (changed variable name from nameNumSelect to nameNumSelectBoxIt for diagnostic purposes)

nameNumSelectBoxIt = $("select#nameNumberSelect1").selectBoxIt({theme:"jquerymobile"})

. . .

// selectBoxIt approach

  for (var i = 0; i < allNameNumsArrayKeys.length; i++)
    {
    if (!farmLoginBool)
      {
      nameNumSelectBoxIt.append($("<option >", {"text" : allNameNumsArrayDescs[i], "value" : allNameNumsArrayKeys[i]}));
      }
    else if (allNameNumsArrayKeys[i] == username)
      {
      nameNumSelectBoxIt.append($("<option selected />", {"text" : allNameNumsArrayDescs[i], "value" : allNameNumsArrayKeys[i]}));
      break;
      }
    }
nameNumSelectBoxIt.data("selectBoxIt").refresh(); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <<<<<<<< This kills the select box.

Do I need to do something else to re-display the select box??

Regards, Bill.

----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Wednesday, December 26, 2012 2:14 PM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

Hey Billy,

Early on in the page, you should not be adding the data("selectBoxIt") method when you are first calling the selectBoxIt plugin. Instead, do this:

nameNumSelect = $("select#nameNumberSelect1").selectBoxIt({theme:"jquerymobile"})

Your code should no longer complain about the append() method not being there. Let me know if you have any more questions and Merry Christmas =)

Greg

— Reply to this email directly or view it on GitHub.

gfranko commented 11 years ago

It looks like you are incorrectly adding a dynamic selected option. Below is how you would append a dynamic select box option that is selected

nameNumSelectBoxIt.append($("<option />", {"text" : allNameNumsArrayDescs[i], "value" : allNameNumsArrayKeys[i], "selected": "selected"}));

Let me know if that works!

chopperbilly commented 11 years ago

Hi Greg,

Well - definately my error in that line - thank you! But - the refresh() still causes the select box to disappear, and not re-appear. (I am using Phonegap, Eclipse and testing on a Samsung Galaxy SIII (Android) )

Just by the way, that error line was not being run as I was running as an admin person and the "else" bit was being used. However, either way, it still fails.

Code is now:

for (var i = 0; i < allNameNumsArrayKeys.length; i++) { if (!farmLoginBool) { nameNumSelectBoxIt.append($("

Your jsFiddle works on Chrome, but not on my smartphone test system.

Thanks in anticipation!

Regards, Bill. ----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Monday, January 07, 2013 7:37 PM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

It looks like you are incorrectly adding a dynamic selected option. Below is how you would append a dynamic select box option that is selected

nameNumSelectBoxIt.append($("

— Reply to this email directly or view it on GitHub.

gfranko commented 11 years ago

Hey Bill, it looks like there was a refresh() method bug for mobile devices only. That bug should now be fixed in SelectBoxIt v2.6.0. You can get the new code here. Let me know if that fixes your issues! Thanks!

chopperbilly commented 11 years ago

No good Greg, still the same - refresh kills the select box and doesn't re-display it.

is there any diagnostic code that I could insert into your selectBoxIt.js that might help somehow?

(I tried inserting an alert into the refresh:function ........ code, but it didn't show - but this could be lack of knowledge on my part as to how to do this into a minified file.)

the following is the correct way to call the refresh function as follows, isn't it?

nameNumSelectBoxIt.data("selectBoxIt").refresh();

Regards Bill.

----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Tuesday, January 08, 2013 9:15 PM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

Hey Bill, it looks like there was a refresh() method bug for mobile devices only. That bug should now be fixed in SelectBoxIt v2.6.0. You can get the new code here. Let me know if that fixes your issues! Thanks!

— Reply to this email directly or view it on GitHub.

chopperbilly commented 11 years ago

Hi Greg,

my humblemost apoplexies - your latest selectBoxIt.js DOES fix the problem - I had not changed the name of the .js file to be included, and it was using the earlier one.

Once again, I am sorry for my blunder.

But I'll keep on truckin', who knows, there may yet be something else to discover!

Many thanks, Bill. ----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Tuesday, January 08, 2013 9:15 PM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

Hey Bill, it looks like there was a refresh() method bug for mobile devices only. That bug should now be fixed in SelectBoxIt v2.6.0. You can get the new code here. Let me know if that fixes your issues! Thanks!

— Reply to this email directly or view it on GitHub.

gfranko commented 11 years ago

Awesome, I'm glad it works for you now! And please continue to report any bugs/new features, because you are only making the project better =)

chopperbilly commented 11 years ago

Hi Greg,

apropos your wish for more work to keep you up even more at night ;=) here's a thought:

Our testers have mentioned that when a (selectBoxIt) select box is used as a menu, and there are more items than will show in the allocated height, it would be useful to have some sort of a scroll bar indication that more items are available - perhaps like the iScroll scroll bar (thin line on the right-hand-side of the box) or a little down-arrow attached to the right of the last option.

I will leave you with this humbly offered thought ...

All the best, Bill. ----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Thursday, January 10, 2013 6:53 AM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

Awesome, I'm glad it works for you now! And please continue to report any bugs/new features, because you are only making the project better =)

— Reply to this email directly or view it on GitHub.

gfranko commented 11 years ago

Good feedback! I will definitely look into having a robust and consistent custom scroll bar (potentially using iScroll). I'll let you know when that happens (probably at least a few weeks).

chopperbilly commented 11 years ago

Hi Greg, Sorry, couldn't stay away!

(Mobile again, as usual) ... Android: We notice that if a selectBoxIt-ed select box has more items than will fit in the designated height, and you need to scroll to see the others, then if there are disabled items among those and you scroll, the disabled items sometimes get shifted and overlayed on top of preceding items, leaving a gap where they would have been. Touch the select box and the correct display is restored. Also for some reason this select box and this select box only WILL NOT display selectBoxIt-ed on an iPhone (it displays the iPhone native select box just fine). (In the case of the iPhone I'm not sure if the disabled items have anything to do with it not displaying selectBoxIt-ed). ----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Thursday, January 10, 2013 10:53 AM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

Good feedback! I will definitely look into having a robust and consistent custom scroll bar (potentially using iScroll). I'll let you know when that happens (probably at least a few weeks).

— Reply to this email directly or view it on GitHub.

chopperbilly commented 11 years ago

Hi Greg,

Ignore last email, I clicked the send button by mistake.

Sorry, couldn't stay away!

(Mobile again, as usual) ... Android: We notice that if a selectBoxIt-ed select box has more items than will fit in the designated height, and you need to scroll to see the others, then if there are disabled items among those and you scroll, the disabled items sometimes get shifted and overlayed on top of preceding items, leaving a gap where they would have been. Touch the select box and the correct display is restored. Also for some reason this select box and this select box only WILL NOT display selectBoxIt-ed on an iPhone (it displays the iPhone native select box just fine).

FURTHER NOTES: (1) I have tried disabling an option on another selectBoxIt-ed select box, and it still works selectBoxIt-ed on an iPhone. (2) I note that in the case of the select box described as above, the options text shows in blue and can not be changed by my custom .css file, as follows:

menuSelect1SelectBoxIt, #menuSelect1SelectBoxItOptions {

width:240px;
max-height:150px;
min-width: 200px;
font: 16px Helvetica, Arial;
color:red; /\* This only works on the "button" (see below) (i.e. not-dropped-down select box - it DOES NOT work on the options !!!<<<<<<<<<<<<<<<<*/

}

/* Dropdown List Box Text _/

menuSelect1SelectBoxItText {

font: 16px Helvetica, Arial; color:red; /_ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ text-indent: 5px; line-height: 30px; overflow: hidden; float: left; white-space: nowrap;

}

nameNumberSelect1SelectBoxIt, #nameNumberSelect1SelectBoxItOptions,

farmNumberSelect1SelectBoxIt, #farmNumberSelect1SelectBoxItOptions {

width:115px; min-width: 115px; font: 16px Helvetica, Arial; color:red; /* this works on these select boxes, both on the "button" and on the select box options !!!!<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/ }

I'm not sure what the problem(s) is (are), and it may not be yours - but I'm stumped!!!

Regards Bill. ----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Thursday, January 10, 2013 10:53 AM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

Good feedback! I will definitely look into having a robust and consistent custom scroll bar (potentially using iScroll). I'll let you know when that happens (probably at least a few weeks).

— Reply to this email directly or view it on GitHub.

chopperbilly commented 11 years ago

Hi Greg,

(made this High priority so you didn't waste time on it)

I discovered why the one and only select box that had the options in blue did have them in blue - the colour (oops color for you) was taken from the Themeroller LINKS color!!!. I changed the Themeroller Content Body > Links color on a whim and hey presto, the select box now has the options in (black). So somehow the Themeroller setting for Links was overriding the color set in my custom css - why, I have no idea. Anyway, this may help someone else who strikes this problem.

My previous email re disabled options sometimes getting shifted and overlaying others if you scroll, still applies.

Just so I know what time it is where you are, where do you live??

We at work here seem to be neverendingly doing stuff on the "bleeding edge"....

Regards Bill. ----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Thursday, January 10, 2013 10:53 AM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

Good feedback! I will definitely look into having a robust and consistent custom scroll bar (potentially using iScroll). I'll let you know when that happens (probably at least a few weeks).

— Reply to this email directly or view it on GitHub.

gfranko commented 11 years ago

@chopperbilly For the mobile support, SelectBoxIt internally positions the original select box directly over the new drop down and set's an opacity of 0 to hide the original select box (and let the SelectBoxIt drop down be the only visible element). This means that whenever you interact with the drop down on a mobile device, you are actually interacting with the native select box. The issues you are seeing with disabled items on mobile are most likely mobile operating system bugs and not SelectBoxIt bugs. Until mobile OS's provide better support for select boxes (IOS6 is a start) there is not much we can do about it unfortunately.

I also live in the US (VA), so US Eastern Standard Time.

chopperbilly commented 11 years ago

Hi Greg,

Thanks for that. I guess yoou'll be sick of me by now!

I really do appreciate your very prompt responses and additions/fixes where appropriate, and look forward to the scroll bar, and Multiple select select boxes when you find time to get around to those.

Meanwhile i have fixed the problem where that specific select box mentioned in a previous email simply would not display selectBoxIt-ed on iPhones - it appears to be that I had to use 'data-role':"fieldcontain" instead of 'data-role':"content" for the select box container, although it worked OK on Android devices. At least that is what I ended up with, and don't have time to go backwards on code versions. I also ended up using the var name instead of the $('# ..id,,') for the container, but why !!@#$$%!!!. Very frustrating.

Kind regards, Bill.

----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Thursday, January 10, 2013 6:32 PM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

@chopperbilly For the mobile support, SelectBoxIt internally positions the original select box directly over the new drop down and set's an opacity of 0 to hide the original select box (and let the SelectBoxIt drop down be the only visible element). This means that whenever you interact with the drop down on a mobile device, you are actually interacting with the native select box. The issues you are seeing with disabled items on mobile are most likely mobile operating system bugs and not SelectBoxIt bugs. Until mobile OS's provide better support for select boxes (IOS6 is a start) there is not much we can do about it unfortunately.

— Reply to this email directly or view it on GitHub.

chopperbilly commented 11 years ago

Hi Greg, I noticed v 2.9.9 was available, but when I try to use it (mobile device) none of the select boxes get selectBoxIt-ed.

Do I need to do something else use-wise, or shouldn't I be trying this version?

Regards, Bill.

gfranko commented 11 years ago

Do you have a public url that you could show me? Version 2.9.9 should be stable.

chopperbilly commented 11 years ago

No, We are still developing for iPhone and Android only. All I can say is that 2.6 works fine, but when I try 2.9.9 none of the select boxes on any page get converted. I'm well prepared to admit that I may not be doing something I should be, but the straight swap of the .js file simply doesn't work for me.

Sorry to be a nuisance!

Rgds Bill. ----- Original Message ----- From: Greg Franko To: gfranko/jquery.selectBoxIt.js Cc: chopperbilly Sent: Wednesday, January 30, 2013 4:25 PM Subject: Re: [jquery.selectBoxIt.js] selectBoxIt with jQuery Mobile Themeroller (#68)

Do you have a public url that you could show me? Version 2.9.9 should be stable.

— Reply to this email directly or view it on GitHub.

gfranko commented 11 years ago

Something new was added in v2.9.0 to only allow selectBoxIt to be called on a select box element. This could be your issue. Could you copy and paste how you are initially calling the plugin?

chopperbilly commented 11 years ago

OK, here's an example:

. . . $('

// Products
$('<label>', {'class':"ui-block-c", 'width':"27%", 'align':"right", 'html':"Product:&nbsp;&nbsp;"}).appendTo(detailsGrid4);
var productTypeContainer = $('<div>', {'class':"ui-block-d", 'width':"30%", 'data-role':"controlgroup", 'data-mini':"true", 'display':"inline", 'id':"ProductTypeContainer" }).appendTo(detailsGrid4);

)

NEXT LINE and following changed to that shown in bold - i.e. addition of $( ...: ////productTypeSelect = '