JQueryMobile Datebox - link without input box - jquery-mobile

I'm looking to have a small cal icon (or the one embedded in input box) when clicked has the standard behavior of "popup calendar" and upon selection fires onClick event or function.
The basic calendar is:
<input name="mydate" id="mydate" type="date" data-role="date box" data-options='{"mode": "calbox"}'>
I would like it to only be an icon in the right side of the header. Here is my existing header code that has a "+" as a link to OnClick event.
<div data-role="header" class="tb">
<h1>MyDate</h1>
<a class="ui-btn-right" id="myplus" onclick="openPickDate();">+</a>
</div>

Here is a jsFiddle: http://jsfiddle.net/ezanker/LS3g6/1/
The HTML markup to include a hidden datebox in the header with a button at top right is as follows:
<div data-role="header">
<h1>My page</h1>
<a data-role="button" id="myplus" class="ui-btn-right" >+</a>
<input name="mydate" id="mydate" type="date" data-role="datebox" data-options='{"mode": "calbox", "hideInput": "true", "centerHoriz": "true", "closeCallback":"onCLoseMyDate();"}' />
</div>
Setting hideInput to true hides the calendar input box, centerHoriz centers the popup on the screen and the closeCallback is called when you select a date and close the popup.
To launch the popup, handle the click event on the myplus button:
$('#myplus').on('click', function() {
$('#mydate').datebox('open');
});
Then supply the callback function:
function onCLoseMyDate(){
var dateObject = $('#mydate').datebox('getTheDate');
alert(dateObject);
}

Related

Unable to focus Input element inside a Bootstrap Popover inside a jQuery UI Dialog

I am having a difficult time getting this to work. I have a link that opens a jQuery UI Dialog which contains links. Those links open a Bootstrap popover which contain an input field. For some reason, the input field is not editable.
See: http://www.bootply.com/Z46ZXA133U
Markup :
<div id="dialog">
<a data-placement="bottom" data-toggle="popover" data-title="Login" data-container=".ui-front" type="button" data-html="true" href="#" id="login">Login</a>
</div>
<form id="popover-content" style="display:none">
<input type="text" value="try changing me">
</form>
Script :
$( "#dialog" ).dialog({
height: 300,
width: 350,
modal: true,
});
$("[data-toggle=popover]").popover({
html: true,
content: function() {
return $('#popover-content').html();
}
});
This is because you have
data-container="body"
on your popover. At the same time, ui-widget-overlay and ui-front covers the body area entirely, preventing clicks and keyboard events from being "sent" from body to the popover.
Change to
data-container=".ui-front"
and you are good. Forked bootply -> http://www.bootply.com/AXpc6PKuSO
in my case change data-container="body" to .ui-front did not help!
But the direction is right
I get modal body container selector and use them!
container: '#myModal-2 > section > div.modal-dialog > div',
Try to explain: if you use container='body' and use modal then modal overlay is blocking focus on body elements

how to make side by side controlgroups

these appear one above the other inside the data-role="page" div and I would like them horizontal "side by side" (preferably the second fieldset on the right, the first fieldset to the left with a shrinking gap spacing them) , does anyone know the "right" way to do this? i.e. so that they are not one above the other but side by side and work with resizing?
<fieldset data-role="controlgroup" data-type="horizontal" >
<button data-inline="true" data-icon="refresh" data-theme="d">save</button>
back
</fieldset>
<fieldset data-role="controlgroup" data-type="horizontal" >
<input type="checkbox" name="selectallbox" id="selectallbox" class="checkable selectall">
<label for="selectallbox">select all</label>
</fieldset

How to make Drop down panel in jQuery mobile 1.4.0?

I have the following Panel in my jQuery mobile app , I want to make it to be drop down as appears in the following image rather than to be slide from the page edge . Is this can be done in jQuery mobile and How can i do this ?
<div data-role="page" id="MainPage" >
<div data-role="panel" id="Mainnavpanel" data-theme="b" data-display="overlay" data- position="right" data-position-fixed="true">
<ul data-role="listview"><li>
<a href="#MainPageheader" data-rel="close" class="ui-btn" >Close</a></li>
<li>Page1</li>
<li>Page2</li>
<li>Page3</li>
</ul>
</div>
<div data-role="header" id="MainPageheader" data-position="fixed" data-tap- toggle="false" data-fullscreen="false">
<div> <font size="6px"> Main Page </font></div>
</div>
<div data-role="content" >
//content
</div>
</div>
You can use popup widget to simulate dropdown menu.
As of jQuery Mobile 1.4, a new attribute data-arrow is added to popup widget. This creates an arrow which can be positioned anywhere in popup.
Arrow:
The popup can display an arrow along one of its edges when it opens if the data-arrow attribute is set. The attribute can take a value of true, false, or a string containing a comma-separated list of edge abbreviations ("l" for left, "t" for top, "r" for right, and "b" for bottom). For example, if you set data-arrow="r,b" then the arrow will only ever appear along the bottom or right edge of the popup. true is the same as "l,t,r,b" and false or "" indicates that the popup should be displayed without an arrow.
HTML
<div data-role="popup" id="popupID" data-arrow="t">
<!-- content -->
</div>
Add data-rel="popup" to button to call popup.
Menu
To modify arrow's size, check this link.
Demo

jquery ui dialog: ui-icons showing up weird

When adding an ui-icon element to a jquery dialog, something weird is displayed instead of the requested icon - (check here for an example: http://jsfiddle.net/aE2Fb/)
It seems like ui-state-default somehow hides the actual icon, because if I remove it, then icon shows up ok. Note that same issue occurrs with ui-state-hover as well.
<div id="dialog" title="Basic dialog" class="">
<span class="ui-icon ui-state-default ui-icon-plusthick ui-corner-all" ></span>
</div>
$(function() {
$( "#dialog" ).dialog();
});
Similar topic was discussed here:jquery ui Portlet : incorrect effect on hover ( ui-state-hover ), but the "fix" was not explained at all and therefore its not really clear, what is going on...
When you put the div into a jQuery UI dialog, you add a load of extra parents, and extra classes - with the result that the icon image file you wanted is getting over-ridden twice.
The first override is from the css for the standard widget background image, which also sets the image position to '50% 50%' - so putting the middle of the image in your button. This then again gets over-ridden back to the correct icon image file, but without any position settings - so you end up seeing the middle of the icon image in your button.
Try putting the icon span inside another container, and move the ui-state-default and ui-corner-all classes to the container instead:
http://jsfiddle.net/7CLL6/
<div id="dialog" title="Basic dialog" class="">
<span class='ui-state-default ui-corner-all'>
<span class="ui-button ui-icon ui-icon-plusthick"></span>
</span>
</div>

dynamically change radio button height and font size in jquery mobile

I'm trying to change height and font size of horizontal controlgroup radio buttons dynamically with jquery mobile 1.2.1
I can change size and font, but with some values the buttons are displayed toghether with the basic radio selector as in
http://picpaste.com/Capture-94sE5bZi.PNG
http://jsfiddle.net/mauix/VVpR9/15/
<body>
<div data-role="page" id="home">
<div data-role="content">
<form>
<fieldset data-role="controlgroup" data-type="horizontal" id="btnc1">
<input name="rc" id="rca" value="on" checked="checked" type="radio">
<label for="rca">#1</label>
<input name="rc" id="rcb" value="off" type="radio">
<label for="rcb">#2</label>
<input name="rc" id="rcc" value="other" type="radio">
<label for="rcc">#3</label>
</fieldset>
</form>
</div>
</div>
</body>
<script>
$('#rca').on('click', function(){
$('.ui-radio').css('height','100px');
$('.ui-radio').children().children().css('font-size','18px');
});
$('#rcb').on('click', function(){
$('.ui-radio').css('height','60px');
$('.ui-radio').children().children().css('font-size','14px');
});
$('#rcc').on('click', function(){
$('.ui-radio').css('height','30px');
$('.ui-radio').children().children().css('font-size','10px');
});
</script>
thanks for help
jQM enhances the radio button by replacing its markup, however, it leaves the original input tag in the dom under the new markup vertically centered within the radio div. When you set the height to 100px, the enhanced button stays at the top while the input moves to the middle and becomes visible. Here are 2 options:
Don't resize the button, just change the font size and let the buttons auto-size with the font changes:
DEMO
If you need the button size changed to exact height, you can use CSS to hide the input:
.ui-radio input{
display: none;
}
DEMO

Resources