Unable to scroll select options in modal dialog (Chrome) - jquery-ui

I have a form within a dialog that has a large number of select option elements. This works fine in IE and FF, but in Chrome, I am unable to scroll through the options. I can select them by selecting an option, then after the options collapse back down, use the arrow keys to go through the list. I am using Chrome Version 32.0.1700.76 and jQuery 1.9.1. I did attempt it using 1.10.2 as well and it did not fix the problem. My fiddle example uses 1.9.1 because selecting 1.10.2 did not allow be to include jQuery UI 1.9.2. You can even see in fiddle that the framework select input is not scrollable. Thanks.
http://jsfiddle.net/4mH8a/19/
HTML:
<form>
<input type="button" value="Open Modal" onclick="$('#divSelect').dialog('open');" />
</form>
<div id="divSelect" style="display:none">
<form>
<select name="lotsofoptions">
<option value="1">option 1</option>
<option value="2">option 2</option>
<option value="3">option 3</option>
<option value="4">option 4</option>
<option value="5">option 5</option>
<option value="6">option 6</option>
<option value="7">option 7</option>
<option value="8">option 8</option>
<option value="9">option 9</option>
<option value="10">option 10</option>
<option value="11">option 11</option>
<option value="12">option 12</option>
<option value="13">option 13</option>
<option value="14">option 14</option>
<option value="15">option 15</option>
<option value="16">option 16</option>
<option value="17">option 17</option>
<option value="18">option 18</option>
<option value="19">option 19</option>
<option value="20">option 20</option>
<option value="21">option 21</option>
<option value="22">option 22</option>
<option value="23">option 23</option>
<option value="24">option 24</option>
<option value="25">option 25</option>
<option value="26">option 26</option>
<option value="27">option 27</option>
<option value="28">option 28</option>
<option value="29">option 29</option>
<option value="30">option 30</option>
</select>
</form>
</div>
JS:
$(document).ready(function(){
// Modal dialogs
$('#divSelect').dialog( { autoOpen:false,
modal: true,
title: 'Unable to scroll',
open: function (event, ui) { window.setTimeout(function () {
jQuery(document).unbind('mousedown.dialog-overlay').unbind('mouseup.dialog-overlay'); }, 100);
}
} );
});

Related

I want to generate select2 on button click

I'm adding select2 element like this
//HTML Code
<html>
<select id="select2Basic" class="select2 form-select form-select-lg">
<option value="1"> 1 </option>
<option value="2"> 2 </option>
<option value="3"> 2 </option>
</select>
<select id="select3Basic" class="select2 form-select form-select-lg">
<option value="4"> 4 </option>
<option value="5"> 5 </option>
<option value="6"> 6 </option>
</select>
</html>
//Jquery
<script>
$("#select2Basic").select2(); //initialise select2 using id
$("#select3Basic").select2();
</script>
// I can't use same id on multiple element, that wont work.
Now i want a button that generate select2 element when clicked

how can i set a select menu in jquery mobile to the local storage?

I have a select menu in jquery mobile and I want to set it to the local storage and then later to get the values from it. This is so if a user selects a car it will be able to delete the car from the list?
Does anyone know how to accomplish this?
<div data-role="fieldcontain">
<label for="select1">Choose a car to rent:</label>
<select name="select1" id="select1" onchange="selectvalue(this.value);">
<option value="97-113-13">Avenger </option>
<option value="97-225-13">Caravan </option>
<option value="97-112-13">Focus </option>
<option value="97-119-13">Escape</option>
<option value="97-226-13">E 350</option>
<option value="97-227-13">Mustang</option>
<option value=" 97-118-13">Wrangler</option>
<option value="97-223-13">Grand Cherokee</option>
<option value="97-111-13">Picanto</option>
<option value="97-114-13">Galant</option>
<option value="97-115-13">Altima</option>
<option value="97-116-13">Juke</option>
<option value="97-222-13">Corolla</option>
</select>
</div>
DEMO
<div data-role="fieldcontain">
<label for="selCar">Select car:</label>
<select name="selCar" id="selCar">
<option value="97-113-13">Avenger</option>
<option value="97-225-13">Caravan</option>
<option value="97-112-13">Focus</option>
<option value="97-119-13">Escape</option>
<option value="97-226-13">E 350</option>
<option value="97-227-13">Mustang</option>
<option value=" 97-118-13">Wrangler</option>
<option value="97-223-13">Grand Cherokee</option>
<option value="97-111-13">Picanto</option>
<option value="97-114-13">Galant</option>
<option value="97-115-13">Altima</option>
<option value="97-116-13">Juke</option>
<option value="97-222-13">Corolla</option>
</select>
</div>
Each time you submit the form, get the currently selected value from the select menu and save it to localStorage. Each time the page is created, read the value from localStorage and then remove it from the options list:
$(document).on("pagecreate", "#page1", function(){
RemovePreviouslySelected();
$("#btnSubmit").on("click", function(){
var selVal = $("#selCar").val();
localStorage.setItem("selectedCar", selVal);
});
});
function RemovePreviouslySelected(){
var prev = localStorage.getItem("selectedCar");
if (prev){
$("#selCar option").each(function(index){
if ($(this).prop("value") == prev){
$(this).remove();
return;
}
});
}
}

How to make a custom select box with filter using jQuery Mobile?

I am having a problem with jQuery Mobile. I want to make a custom select box with search option on the top like in the ul of jQuery mobile. I have made a custom select box using jQuery mobile but cannot add the search bar on it. I want exactly the thing like this:
http://jsfiddle.net/sEMyT/2/
<!DOCTYPE html>
<html>
<head>
<link class="jsbin" href="http://code.jquery.com/mobile/1.0b2/jquery.mobile-1.0b2.min.css" rel="stylesheet" type="text/css" />
<script class="jsbin" src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script class="jsbin" src="https://github.com/downloads/aliok/jquery-mobile/jquery.mobile_selectmenu_filter_01.js"></script>
<title>JS Bin</title>
</head>
<body>
<div data-role="page">
<div data-role="content">
<h2>Select menu options filtering</h2>
<p>The mobile browsers are limited and sometimes it is annoying to scroll a long list. For this kind of selects, you can use <code>data-filter</code> attribute alongside with <code>data-force-dialog</code> and <code>data-native</code> attributes to have a select menu with search bar filtering its options.</p>
Refresh the selectmenu (forcerebuild) with clearing the filter value
<div data-role="fieldcontain">
<label for="select-choice-12" class="select">Your state:</label>
<select name="select-choice-12" id="select-choice-12" data-native-menu="false" data-force-dialog="true" data-native-menu="false" data-filter="true">
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
<option value="FL">Florida</option>
<option value="GA">Georgia</option>
<option value="HI">Hawaii</option>
<option value="ID">Idaho</option>
<option value="IL">Illinois</option>
<option value="IN">Indiana</option>
<option value="IA">Iowa</option>
<option value="KS">Kansas</option>
<option value="KY">Kentucky</option>
<option value="LA">Louisiana</option>
<option value="ME">Maine</option>
<option value="MD">Maryland</option>
<option value="MA">Massachusetts</option>
<option value="MI">Michigan</option>
<option value="MN">Minnesota</option>
<option value="MS">Mississippi</option>
<option value="MO">Missouri</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NV">Nevada</option>
<option value="NH">New Hampshire</option>
<option value="NJ">New Jersey</option>
<option value="NM">New Mexico</option>
<option value="NY">New York</option>
<option value="NC">North Carolina</option>
<option value="ND">North Dakota</option>
<option value="OH">Ohio</option>
<option value="OK">Oklahoma</option>
<option value="OR">Oregon</option>
<option value="PA">Pennsylvania</option>
<option value="RI">Rhode Island</option>
<option value="SC">South Carolina</option>
<option value="SD">South Dakota</option>
<option value="TN">Tennessee</option>
<option value="TX">Texas</option>
<option value="UT">Utah</option>
<option value="VT">Vermont</option>
<option value="VA">Virginia</option>
<option value="WA">Washington</option>
<option value="WV">West Virginia</option>
<option value="WI">Wisconsin</option>
<option value="WY">Wyoming</option>
</select>
</div>
You can see the source code at https://github.com/aliok/jquery-mobile/commits/selectmenu-forceDialog/
<br/>
<br/>
Developed by Ali Ok - #aliok_tr
</div>
</div>
</body>
</html>
But the problem with that it is customized with a very old version of jQuery Mobile and I am using the latest version.
You could just follow the example on the JQM demo pages Filter inside Custom Select
I hope you can Use Select2 or Chosen
Select2 is a jQuery based replacement for select boxes. It supports searching, remote data sets, and infinite scrolling of results.
For more details and Demo : check Select2 or Try Chosen
Its implemented in our some projects and its works fine.
check out this in the jquery mobile site:
selectmenu-custom-filter
this is the original jquery mobile solution
this link its the best https://github.com/studiosedition/JQM-Custom-Search-Filtering-Example i tested
recommended by http://www.peachpit.com/articles/article.aspx?p=1929169
other example for custom filter
http://jsfiddle.net/dondavidml/ekbo4uy5/
$("ul").listview('option', 'filterCallback', function (text, searchValue) {
console.log(" searchValue " + searchValue.toUpperCase() + " text " + text.substring(0, searchValue.length).toUpperCase());
if (searchValue.toUpperCase() == (text.substring(0, searchValue.length).toUpperCase())) {
return false;
}
return true; });
be careful, the order matters in the imports like this
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="js/search-filter.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
:D

Jquery Mobile - Multiple Select Menu redirecting issue

I am having a problem with Multiple Select Menu in a jquery-mobile app.
Here is my sample Code (just for demo) http://jsfiddle.net/yesvin/aSBCX/
<div data-role="page" id="one">
<div data-role="content">
<label for="sel">Select the Options </label>
<select name="sel" id="sel" data-native-menu="false" multiple="multiple" >
<option value="">Slect the Options</option>
<option value="1">Prod 1</option>
<option value="2">Prod 2</option>
<option value="3">Prod 3</option>
<option value="4">Prod 4</option>
<option value="5">Prod 5</option>
<option value="6">Prod 6</option>
<option value="7">Prod 7</option>
<option value="8">Prod 8</option>
<option value="9">Prod 9</option>
<option value="10">Prod 10</option>
<option value="11">Prod 11</option>
<option value="12">Prod 12</option>
<option value="13">Prod 13</option>
<option value="14">Prod 14</option>
<option value="15">Prod 15</option>
<option value="16">Prod 16</option>
<option value="17">Prod 17</option>
<option value="18">Prod 18</option>
<option value="19">Prod 19</option>
<option value="20">Prod 20</option>
</select>
click
</div>
</div>
<div data-role="page" id="two">
<div data-role="content">
page 2
</div>
After changing the select menu i need to change the page by clicking the button below the menu. But what happens is, the page change is occured but it will automatically redirect to the previous page where the menu has (In Android). It works fine in desktop. How to prevent this in mobile? and what happens exactly?
Thanks in advance.
NOTE: This is same as this question
but the solution is not working for me...
Even i tried with data-ajax="false" but no luck...

zurb foundation error class not rendering correctly

im using foundation 3, and have set the class of custom on my form, though the issue im having is with the select dropdowns and error class not working the way it should.
what i am hoping for is that i can have the widths of the select boxes to be set to the same column width as the error messages as to make the view looked polished
<div class="four columns">
<select class="four columns" id="event_location_id" name="event[location_id]" style="display: none; "><option value="">None</option>
<option value="8">APK</option>
<option value="10">BAL</option>
<option value="11">BANK</option>
<option value="12">BANY</option>
<option value="13">BEN1</option>
<option value="14">BEN2</option>
<option value="15">BER</option>
<option value="16">BRU</option>
<option value="17">BTN</option>
<option value="18">CAM</option>
<option value="19">CAUL-Ind</option>
<option value="20">CER</option>
<option value="22">DAN</option>
<option value="23">DON</option>
<option value="24">DRO</option>
<option value="25">ELG</option>
<option value="26">ELT</option>
<option value="27">ES1</option>
<option value="28">ES2</option>
<option value="29">F-1</option>
<option value="30">F-2</option>
<option value="31">FP</option>
<option value="32">GEL</option>
<option value="33">GRN</option>
<option value="34">GRN-2</option>
<option value="35">H-1</option>
<option value="36">H-2</option>
<option value="37">HAL-1</option>
<option value="38">HAL-2</option>
<option value="39">HHF (prev WAV)</option>
<option value="40">HUN</option>
<option value="41">KNG</option>
<option value="42">KNX</option>
<option value="43">LAT</option>
<option value="45">MEL</option>
<option value="46">MGV</option>
<option value="47">MHS</option>
<option value="48">MNT</option>
<option value="49">MON</option>
<option value="50">MON-Ind</option>
<option value="51">MUH</option>
<option value="52">PCK</option>
<option value="53">PEGS</option>
<option value="54">PHC</option>
<option value="55">PSF</option>
<option value="56">RMIT</option>
<option value="57">S-1</option>
<option value="58">S-2</option>
<option value="59">S.N.H.C.</option>
<option value="60">SHP</option>
<option value="61">SKW</option>
<option value="62">STB</option>
<option value="63">T.B.A.</option>
<option value="64">TRI</option>
<option value="65">WARN</option>
<option value="66">WER</option>
<option value="67">WGS</option>
<option value="68">WGW</option>
<option value="69">WHF</option>
<option value="71">YAR</option>
<option value="72">YVG</option>
<option value="21">CHU</option>
<option value="70">WOD</option>
<option value="73">Test</option>
<option value="9">ASH</option>
<option value="7">ALT</option>
<option value="44">MBN</option></select><div class="custom dropdown" style="width: 155px; ">None<ul style="width: 155px; "><li class="selected">None</li><li>APK</li><li>BAL</li><li>BANK</li><li>BANY</li><li>BEN1</li><li>BEN2</li><li>BER</li><li>BRU</li><li>BTN</li><li>CAM</li><li>CAUL-Ind</li><li>CER</li><li>DAN</li><li>DON</li><li>DRO</li><li>ELG</li><li>ELT</li><li>ES1</li><li>ES2</li><li>F-1</li><li>F-2</li><li>FP</li><li>GEL</li><li>GRN</li><li>GRN-2</li><li>H-1</li><li>H-2</li><li>HAL-1</li><li>HAL-2</li><li>HHF (prev WAV)</li><li>HUN</li><li>KNG</li><li>KNX</li><li>LAT</li><li>MEL</li><li>MGV</li><li>MHS</li><li>MNT</li><li>MON</li><li>MON-Ind</li><li>MUH</li><li>PCK</li><li>PEGS</li><li>PHC</li><li>PSF</li><li>RMIT</li><li>S-1</li><li>S-2</li><li>S.N.H.C.</li><li>SHP</li><li>SKW</li><li>STB</li><li>T.B.A.</li><li>TRI</li><li>WARN</li><li>WER</li><li>WGS</li><li>WGW</li><li>WHF</li><li>YAR</li><li>YVG</li><li>CHU</li><li>WOD</li><li>Test</li><li>ASH</li><li>ALT</li><li>MBN</li></ul></div><small for="event_location_id" class="error">can't be blank</small>
</div>
This is a reported bug (and apparently fixed 6 days ago.)
In the meantime, you can easily fix it with two lines of CSS:
.custom.dropdown {
width: 100% !important; /* fixes width issue */
}
.custom.dropdown + .error {
margin-top: -9px; /* fixes overlapping */
}
You can see it in action here.

Resources