A scrolling List view inside a popup in jQuery mobile? - jquery-mobile

In my phonegap application for Android, I have a popup contains a listview. This is my jsfiddle: http://jsfiddle.net/de2Lf/3/. The problems are that the scroll didn't appear on the emulator and the back button in the header is not working correctly.
Why is the scroll not working? What's wrong with my code? Please help me.
<div data-role="page" >
<div data-role="header" data-theme="b">
Main Page
</div>
<div data-role="content" >
<a href="#mypop" data-rel="popup" id="Btn1" data-role="button" data-inline="true" >Show POPUP </a>
</div>
<div data-role="popup" id="mypop" data-position-to="window" data-corners="false" data- overlay-theme="a" data-dismissible="false" >
<div data-role="header" data-theme="b" >
<a href="" id="ClosePOPUP" data-role="button" data-icon="custom-close-icon" data-iconpos="notext" class="ui-btn-right" ></a>
<div style="text-align:center;float:center;padding-top:11px;" ><font size="6px" color="white">pop</font></div>
</div>
<div id="scrollDiv" class="content" data-role="content" style="background-color: white;overflow-y:scroll; ">
<ul data-role="listview" style="margin: 0 !important;">
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
<li>element</li>
</ul>
</div>
</div>
</div>
java script
$(document.body).on('click','#ClosePOPUP', function(){
$('#mypop').popup('close');
});

This should do the trick for you
android:fadeScrollbars="false"
Or the other option is to update your CSS for the listview to have a height
height: 90% or max-height and overflow-y: scroll

Related

JQM Toolbar (Header and Footer) moving with scrolling Windows phone 8

I am using Cordova with JQuery mobile, it working fine on android, but when made build for Windows Phone 8, the JQM Toolbar(Header and footer) not getting fix, Toolbar little goes up when I am scrolling up page and when I am scrolling down the toolbar little goes down, like below screenshots
http://159.100.223.157/screens/IMG_0712.JPG
http://159.100.223.157/screens/IMG_0713.JPG
here is the code
<div role="main">
<div id="SearchRides" data-role="page" class="page innerPage">
<div class="ui-header ui-bar-a ui-header-fixed header" data-position="fixed">
<h1 aria-level="1" role="heading" class="ui-title">Search</h1>
</div>
<!--end header-->
<div class="projects ui-content content">
<form method="post" action="#">
<div class="ui-field-contain">
<label for="txtFrom" style="text-align: center">Source</label>
<input type="text" name="txtFrom" id="txtFrom" placeholder="To">
</div>
</form>
</div>
<!--end body-->
<div data-theme="a" class="footer" data-role="footer" data-position="fixed">
<div data-role="navbar">
<ul>
<li> </li>
</ul>
</div>
<!--end footer-->
</div>
</div></div>

jQuery Mobile custom select not closing

I have a web application which uses jQuery 1.6.2 and jQuery Mobile 1.0b3. I need to display a list of options, so I used a custom select. I cannot close the select by using the header button, and neither by selecting an option.
The nativeMenu = false is set globally.
I create the select using
<select data-mini="true">
<option value="1">Option1</option>
<option value="2">Option2</option>
</select>
The HTML look like this (there are many more options, so the select goes full-screen):
<div data-role="dialog" data-theme="c" data-overlay-theme="a" tabindex="0"
class="ui-page ui-body-c ui-dialog ui-overlay-a ui-page-active" style="min-height: 480px;">
<div role="dialog" class="ui-dialog-contain ui-corner-all ui-overlay-shadow">
<div data-role="header" class="ui-corner-top ui-header ui-bar-a" role="banner">
<a href="#" data-icon="delete" data-iconpos="notext"
class="ui-btn-left ui-btn ui-shadow ui-btn-corner-all ui-btn-icon-notext ui-btn-up-a" data-corners="true"
data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="a" title="Close">
<span class="ui-btn-inner ui-btn-corner-all">
<span class="ui-btn-text">Close</span>
<span class="ui-icon ui-icon-delete ui-icon-shadow"> </span>
</span>
</a>
<div class="ui-title"></div>
</div>
<div data-role="content" class="ui-corner-bottom ui-content ui-body-c" role="main">
<ul class="ui-selectmenu-list ui-listview" id="undefined-menu" role="listbox" aria-labelledby="undefined-button"
data-theme="c">
<li data-option-index="0" data-icon="false" class="ui-btn ui-btn-icon-right ui-li ui-btn-active ui-btn-up-c"
role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div"
data-iconpos="right" data-theme="c" aria-selected="true">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
Option1
</div>
</div>
</li>
<li data-option-index="1" data-icon="false" class="ui-btn ui-btn-icon-right ui-li ui-btn-up-c" role="option"
data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right"
data-theme="c" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
Option2
</div>
</div>
</li>
</div>
</div>
</div>
The header button works with jQuery 1.8.3 & jQm 1.2.1 (selecting an option still doesn't work), but changing this versions leads to other problems in my legacy app, so I would prefer a solution for 1.6.2 & jQm 1.0.
Any ideas why the select doesn't work ?
EDIT:
After a couple of days of searching, I found out that the dialog doesn't close because I have set hashListeningEnabled = false. Unfortunately, I cannot change this. I stumbled upon this: https://github.com/jquery/jquery-mobile/issues/2285, but I cannot upgrade the jQm/jQuery version. So I'm left with finding some good alternative for the select. Any suggestions ?
wow... no answer to this... almost one year bfore! and i have the same (or actually similar... soon enough) issue. So here i go with my experience:
(in which i need to mention that i am able to select multiple items but when i hit the cross button over the header... no closing action will follow. so DANG!
i have been trying to figure some kind of workaround for this.. so i started mutating some other jQm pop ups and the problem that i'm facing now is that my solution seems to show different buttons with the html object (each time you click this one only button it goes round the SELECT's items displaying them one at a time inside this one button, very weird... at least for my rookie experience with jquery mobile, so maybe its a simple couple of options that i didnt kneew how to set, but im being blind to the solution.
So, what do i need to show a nice popup like the one in the picture (also code pasted below) from a common SELECT (HTML OBJECT) ?
(please take a look of what i intent to achive (the look and feel)
h t t p : / / i . s t a c k . i m g u r . c o m /I5q0I.png
And this is the code that i should have (but with the cross working, which is not.)
<div class="ui-popup-container ui-popup-active" id="select-choice-7458-listbox-popup" tabindex="0" style="max-width: 1825px; top: 2788.5px; left: 805.5px;">
<div id="select-choice-7458-listbox" class="ui-selectmenu ui-popup ui-body-a ui-overlay-shadow ui-corner-all">
<div class="ui-header ui-bar-c">
<h1 class="ui-title">
</h1>
<a href="#" class="ui-btn-left ui-btn ui-btn-up-c ui-shadow ui-btn-corner-all ui-btn-icon-notext" data-iconpos="notext" data-icon="delete" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" data-theme="c" title="Close">
<span class="ui-btn-inner">
<span class="ui-btn-text">
Close
</span>
<span class="ui-icon ui-icon-delete ui-icon-shadow">
</span>
</span>
</a>
</div>
<ul class="ui-selectmenu-list ui-listview" id="select-choice-7458-menu" role="listbox" aria-labelledby="select-choice-7458-button" data-theme="c" data-divider-theme="b">
<li data-option-index="0" data-icon="checkbox-off" data-placeholder="true" class="ui-selectmenu-placeholder ui-btn ui-btn-up-c ui-btn-icon-right ui-li-has-arrow ui-li ui-first-child" role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right" data-theme="c" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
</div>
<span class="ui-icon ui-icon-checkbox-off ui-icon-shadow">
</span>
</div>
</li>
<li data-option-index="1" data-icon="checkbox-off" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c" role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right" data-theme="c" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a href="#" tabindex="-1" class="ui-link-inherit">
Scribbling</a>
</div>
<span class="ui-icon ui-icon-checkbox-off ui-icon-shadow">
</span>
</div>
</li>
<li data-option-index="2" data-icon="checkbox-off" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c" role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right" data-theme="c" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a href="#" tabindex="-1" class="ui-link-inherit">
Letter-like symbols</a>
</div>
<span class="ui-icon ui-icon-checkbox-off ui-icon-shadow">
</span>
</div>
</li>
<li data-option-index="3" data-icon="checkbox-off" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c" role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right" data-theme="c" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a href="#" tabindex="-1" class="ui-link-inherit">
Strings of letters</a>
</div>
<span class="ui-icon ui-icon-checkbox-off ui-icon-shadow">
</span>
</div>
</li>
<li data-option-index="4" data-icon="checkbox-off" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c" role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right" data-theme="c" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a href="#" tabindex="-1" class="ui-link-inherit">
Beginning sounds
</a>
</div>
<span class="ui-icon ui-icon-checkbox-off ui-icon-shadow">
</span>
</div>
</li>
<li data-option-index="5" data-icon="checkbox-off" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-btn-up-c" role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right" data-theme="c" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a href="#" tabindex="-1" class="ui-link-inherit">
Ending and medial sounds
</a>
</div>
<span class="ui-icon ui-icon-checkbox-off ui-icon-shadow">
</span>
</div>
</li>
<li data-option-index="6" data-icon="checkbox-off" class="ui-btn ui-btn-icon-right ui-li-has-arrow ui-li ui-last-child ui-btn-up-c" role="option" data-corners="false" data-shadow="false" data-iconshadow="true" data-wrapperels="div" data-iconpos="right" data-theme="c" aria-selected="false">
<div class="ui-btn-inner ui-li">
<div class="ui-btn-text">
<a href="#" tabindex="-1" class="ui-link-inherit">
Conventional writing
</a>
</div>
<span class="ui-icon ui-icon-checkbox-off ui-icon-shadow">
</span>
</div>
</li>
</ul>
</div>
</div>

Jquery Mobile popup triggering by itself

I have a popup set up on the index.html as follows:
<!-- Choice Popup -->
<div class="ui-popup-screen ui-overlay-a ui-screen-hidden" id="popupDialog-screen"></div>
<div data-role="popup" class="ui-popup-container ui-overlay-a" data-transition="pop" id="choicePopup">
<div data-role="popup" id="choicePopup" data-overlay-theme="b" data-theme="c" data-dismissible="false" class="ui-corner-all ui-popup ui-body-c ui-overlay-shadow" aria-disabled="false" data-disabled="false" data-shadow="true" data-corners="true" data-transition="slidedown" data-position-to="window" data-arrow="true" data-arrow-sides="t,b,l,r">
<div data-role="content" data-theme="d" class="ui-corner-bottom ui-content ui-body-d" role="main">
<h1 class="ui-title" role="heading" aria-level="1">Your decision has been made:</h1>
<h2 align="center" id="choice-p"></h2>
<a href="#" data-role="button" data-inline="true" data-rel="back" data-theme="c" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" class="ui-btn ui-btn-up-c ui-shadow ui-btn-corner-all ui-btn-inline">
<span class="ui-btn-inner">
<span class="ui-btn-text">Thanks</span>
</span>
</a>
<a href="#" onclick="eatsome('Food'); return false;" data-role="button" data-inline="true" data-transition="flow" data-theme="b" data-corners="true" data-shadow="true" data-iconshadow="true" data-wrapperels="span" class="ui-btn ui-btn-up-b ui-shadow ui-btn-corner-all ui-btn-inline">
<span class="ui-btn-inner">
<span class="ui-btn-text">Again!</span>
</span>
</a>
</div>
</div>
The problem is, I don't know why its booting on loading, some attribute is triggering it, can anyone find the issue? Thank you
There are several issues with your markup and code:
First of all your markup for the popup looks already jQM-enhanced like being copied from the browser's developer view. Therefore make it normal first. It might look like
<div data-role="popup" id="choicePopup" data-overlay-theme="b" data-theme="c" data-dismissible="false" class="ui-corner-all">
<div data-role="header" data-theme="a" class="ui-corner-top">
<h1></h1>
</div>
<div data-role="content" data-theme="d" class="ui-corner-bottom ui-content">
<h3 class="ui-title">Your decision has been made:</h3>
<a id="btnThanks" href="#" data-role="button" data-inline="true" data-rel="back" data-theme="c">Thanks</a>
<a id="btnAgain" href="#" data-role="button" data-inline="true" data-rel="back" data-transition="flow" data-theme="b">Again!</a>
</div>
</div>
Second a popup markup should reside inside the same page as the link that opens it.
<div data-role="page" id="main">
...
<div data-role="popup" id="choicePopup">
...
</div>
</div>
Third use proper jQM events to place your code that manipulates the content.
Forth Stop using onclick and other on* event attributes with jQM. Once again use proper jQM or jQuery events.
So instead of
<a href="#" onclick="eatsome('Food'); return false;" ... >Again!</a>
use
<a id="#btnAgain" href="#" ... >Again!</a>
$("#btnAgain").click(function(){
eatsome('Food');
return false;
});
Fifth After injecting html you need to call trigger('create') on a parent element to let jQM enhance and style the markup that you injected.
var content = '<form>;
...
content += '</form>;
$("div.settings-content").html(content).trigger("create");
And here is working jsFiddle based on your markup. As you can see the popup doesn't pop up on its own. There are two buttons that show how to open the popup declaratively and programmatically. And content for settings page is injected and styled properly.

jquery-mobile: Collapsible inside list-view

I want to use some collapsible elements inside a listview in jquery mobile. I can set well the collapsible adding a inside the corresponding part, but when the collapsible is not collapsed, the info of collapsible is not inside the collapsible bubble, how can I fix that to have a bubble that include title and description?
Thanks
<div id="dispositivo" data-role="page" data-theme="c" data-cache="refresh">
<div data-role="content" role="main">
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="b">
<li data-role='list-divider'>Titulo</li>
<form id="form_disp" name="form_disp" method="post" action="test.php">
<li data-role='fieldcontain'>
<a id="estado" name="estado" href="#" data-theme="b" data-role="button" data-inline="true">Boton</a>
<div data-role="content" data-inset="true">
<div data-role="collapsible" data-inset="true">
<h3>Info1</h3>
<p>Ahora estamos viendo el info 1</p>
</div>
<div data-role="collapsible">
<h3>Info 2</h3>
<p>Ahora estamos viendo el info 2</p>
</div>
</div>
<button data-theme="b" id="b_conf_disp" data-role="button" data-inline="true" type="submit">Boton 2</button>
</form>
</ul>
</div>
</div>
I think you missed </li> tag.
For something similar you can try using the plugin I wrote that allows certain listview items to be opened inline within the listview.
The Github Repo

jQuery mobile listview and input button overlap

I have the following to display a list of items and a button underneath the list. However the button is overlapping on top of the list. I must be not putting some kind of data-role or another one of their attributes on it.
<div data-role="content" data-theme="b">
<div>
<ul id="listOfSheets" data-role="listview" >
<li class="hidden"> _sheetName</li>
</ul>
</div>
<input id="logout" type="button" value="Sign Out" />
</div><!-- /content -->
Here is what it looks like:
Live Example:
http://jsfiddle.net/B7nhA/ (the problem)
http://jsfiddle.net/B7nhA/1/ (the fix)
You're missing one of the attributes for the listview
data-inset="true"
HTML
<div data-role="content" data-theme="b">
<div>
<ul id="listOfSheets" data-role="listview" data-inset="true">
<li class="hidden">Link 1</li>
<li class="hidden">Link 2</li>
<li class="hidden">Link 3</li>
</ul>
</div>
<input id="logout" type="button" value="Sign Out" />
</div><!-- /content -->
i experienced the same problem. Here is my fix.
<style>
.ui-content .ui-listview
{
margin-top: 5px;
margin-bottom: 5px;
}
</style>
JsFiddle Demo
You dont need to modify your markups.
How about inserting an line break befor the button.Not a clean solution I think.But it will work.
<div data-role="content" data-theme="b">
<div>
<ul id="listOfSheets" data-role="listview" >
<li class="hidden"> _sheetName</li>
</ul>
</div>
<br>
<input id="logout" type="button" value="Sign Out" />
</div><!-- /content -->
I used padding to solve this kind of problems. See below I added padding to the list-container div.
<div data-role="content" data-theme="b">
<div style="padding-bottom:20px">
<ul id="listOfSheets" data-role="listview" >
<li class="hidden">Link 1</li>
<li class="hidden">Link 2</li>
<li class="hidden">Link 3</li>
</ul>
</div>
<input id="logout" type="button" value="Sign Out" />
​​​
Here is a DEMO

Resources