why thems go up when entering the text in text field? [duplicate] - jquery-mobile

This question already has an answer here:
How to handle them jump out(while keyboard open) in query mobile?
(1 answer)
Closed 9 years ago.
I am using jqm .Actually I open the pop up screen on button click .I am facing a problem my them goes up while entering the text.Here is my code..
http://jsfiddle.net/ravi1989/7JqRG/
<div data-role="page" id="Home" >
<div data-role="header" data-theme="b" data-position="fixed" data-tap-toggle="false" >
<h1 class="ui-title" id="hdr" style="text-align:left;margin-left: 20px;">My Cases</h1>
<div class="ui-btn-right" id="headerButtons" data-role="controlgroup" data-type="horizontal">
Setting
Add
Edit
</div>
</div>
<div data-role="content">
<ul data-role="listview" data-inset="true" id="folderData" >
</ul>
<!-- **************Case Information Pop up Start*******************-->
<div data-role="popup" id="CaseInformationScreen" data-close-btn="none" data-overlay-theme="a" data-dismissible="false">
<div data-role="header" data-theme="b" >
Cancel
<h1>Case Information</h1>
Add
</div>
<div data-role="content">
<div><img src="img/Documents.png"/></div>
<div data-role="fieldcontain">
<label for="text-12" style="text-align:top;margin-left: 0px;">Case Name:</label>
<input name="text-12" id="text-12" value="" type="text" class="caseName_h" autocorrect="off">
</div>
<div data-role="fieldcontain">
<label for="caseDate" style="text-align:left;margin-left: 0px;" >Case Date:</label>
<input name="caseDate" id="caseDate" value="" type="date" class="caseDate_h" >
<!--input name="mydate2" id="mydate2" type="date" data-role="datebox" class="caseDate_h" data-options='{"mode": "calbox","useNewStyle":true,"zindex":1200}'/-->
</div>
<div data-role="fieldcontain">
<label for="textarea-12">Case Notes :</label>
<textarea cols="40" rows="8" name="textarea-12" id="text-12" class="caseTextArea_h" autocorrect="off"></textarea>
</div>
</div>
</div>
Please + button on header .Pop up open fill the text black them goes up?

Here is your answer..
window.resize due to virtual keyboard causes issues with jquery mobile
1) Go into jquery.mobile-1.x.x.js
2) Find $.mobile = $.extend() and add the following attributes:
last_width: null,
last_height: null,
3) Modify getScreenHeight to work as follows:
getScreenHeight: function() {
// Native innerHeight returns more accurate value for this across platforms,
// jQuery version is here as a normalized fallback for platforms like Symbian
if (this.last_width == null || this.last_height == null || this.last_width != $( window ).width())
{
this.last_height = window.innerHeight || $( window ).height();
this.last_width = $(window).width();
}
return this.last_height;
}

Related

Delete list element from a confirmation popup

I have a list with delete button for each element , when the user click on the delete button a confirmation dialog appear ,if the user press the OK button i want to delete the list element my problem is how to get the <li> list element index in order to remove it from the list , my code not return the correct index , please help me ..
<div data-role="page">
<div data-role="content">
<ul data-role="listview" id="employeesList" data-inset="true" data-split- icon="delete">
<li><a href="#">
<font class="line1" > Emp1Name</font>
<font class="line2" >Emp1Salary</font>
</a><a href="#DeleteConfirm" data-rel="popup" data-position-to="window" data- transition="pop" >Delete</a></li>
<li><a href="#">
<font class="line1" > Emp2Name</font>
<font class="line2" >Emp2Salary</font>
</a>Delete</li>
</ul>
<div data-role="popup" id="DeleteConfirm" data-overlay-theme="a" data-theme="c" data-dismissible="false" style="width:400px;height:200px;" class="ui-corner-all">
<div data-theme="c" style="text-align:center;float:center;height:53px;padding-top:13px;" >
<font size="6px" >Delete</font>
</div>
<div data-role="content" data-theme="d" class="ui-corner-bottom ui-content">
<font size="5px" >Do you want to delete this Employee?</font>
<BR>
<div style="text-align:center;font-size: 22px;" >
<input type="button" id="No" data-inline="true" data-icon="delete" data-theme="c" value="No " />
<input type="button" id="Yes"data-inline="true" data-icon="check" data- theme="c" value=" Yes" data-corners="false"/>
</div>
</div>
</div>
</div>
Java script code:
var SelectedLi ;
$('#DeleteConfirm').on('click',function(){
SelectedLi= $(this).parent().index();
});
$('#Yes').on('click',function(){
$('#employeesList').remove(SelectedLi);
$('#DeleteConfirm').popup('close');
});
$('#No').on('click' ,function(){
$('#DeleteConfirm').popup('close');
});
You have mistake in binding event to split button, it should be as follows:
var SelectedLi ='' ;
$('[href=#DeleteConfirm]').on('click',function (e) {
// store parent of clicked button
SelectedLi = $(this).closest("li");
});
$('#Yes').on('click',function(){
$(SelectedLi).remove();
$('#employeesList').listview("refresh");
$('#DeleteConfirm').popup('close');
});
$('#No').on('click' ,function(){
$('#DeleteConfirm').popup('close');
});
Demo
This is how I do my popup:
HTML:
<div data-role="popup" id="sterge" data-overlay-theme="a" data-theme="c" data-dismissible="false" style="max-width:400px;" class="ui-corner-all">
<div data-role="header" data-theme="b" class="ui-corner-top">
<h1>Delete?</h1>
</div>
<div data-role="content" data-theme="d" class="ui-corner-bottom ui-content">
<h3 class="ui-title">To Delete Product from Bonus?</h3>
<p>This action cannot be undone.</p>
<input id="giveupButton" data-inline="true" type="button" value="Cancel"/>
<input id="delButton" data-inline="true" onclick="deletebonusproduct();" data-theme="b" type="button" value="Delete"/>
</div>
</div>
JS:
$(document.body).on('click', '.del' ,function(){
li = $(this).parent();
$('#sterge').popup("open");
});
$(document.body).on('click', '#delButton' ,function(){
$('#sterge').popup("close");
li.remove();
});
$(document.body).on('click', '#giveupButton' ,function(){
$('#sterge').popup("close");
});

Panels and fixed-position header/footer

I am trying to use the reveal animation for my panel. However, when jQuery Mobile runs the animation, the header does not slide over as far as the panel does so the header slightly overlaps the panel. See the image here: http://i.imgur.com/fjuDSRe.png
Here's my code:
<div data-role="page" id="taskdetailspage">
<div data-role="header" data-id="navbar" data-position="fixed" data-tap-toggle="false">
Back
<p class="title">Field Service Engineer</p>
Actions
</div>
<div id="taskholder" data-role="content">
</div>
<div data-role="content" id="directionsholder"></div>
<div data-role="panel" data-theme="a" id="taskdetailspanel" data-position="right" data-display="reveal"
data-position-fixed="true">
<h3>Actions</h3>
<ul data-role="listview" data-theme="a">
<li>Update Task Status</li>
<li><a id="directionsButton" href="#">Get Directions</a></li>
<li>Decline Task</li>
</ul>
</div>
<div id="updateStatusPopup" data-role="popup" data-theme="a" data-overlay-theme="a"
data-transition="fade" data-position-to="window">
<div data-role="header">
<h3>Update Task Status</h3>
</div>
<div data-role="content">
<form action="javascript: updateTaskStatus(currentTaskId);">
<fieldset data-role="controlgroup">
<legend>Current Status:</legend>
<input data-theme='a' name="updateStatus" id="arrived" value="Arrived" checked="checked" type="radio">
<label for="arrived">Arrived</label>
<input data-theme='a' name="updateStatus" id="wip" value="Work in Progress" type="radio">
<label for="wip">Work in Progress</label>
<input data-theme='a' name="updateStatus" id="completed" value="Complete" type="radio">
<label for="completed">Complete</label>
</fieldset>
<label for="statusNotes">Status Notes:</label>
<input name="statusNotes" id="statusNotes" value="" type="text">
<fieldset class="ui-grid-a">
<div class="ui-block-a"><input type="submit" value="Update" data-theme='a' id='confirmUpdateButton'></div>
<div class="ui-block-b"><a data-theme='a' data-role='button' data-rel='back'>Cancel</a></div>
</fieldset>
</form>
</div>
</div>
<div id="dialogcontent" data-role="popup" data-theme="a" data-overlay-theme="a"
data-transition="fade" data-position-to="window">
<div data-role="header">
<h3>Confirm Decline Task</h3>
</div>
<p>Are you sure you want to decline this task and remove it from your calendar?</p>
<fieldset class="ui-grid-a">
<div class="ui-block-a"><a data-theme='a' href='#' id='confirmDeclineButton' data-role='button'>Decline</a> </div>
<div class="ui-block-b"><a data-theme='a' href='#' data-role='button' data-rel='back'>Cancel</a></div>
</fieldset>
</div>
I found one other question on SO with a similar description but the solution was unintelligible.
Thanks in advance!

How to resize the text area in query mobile?

Can you please tell me how to resize the text area? Actually the problem is that I open the pop up screen on button click. In my pop up screen I have one text area (having small area).
<textarea cols="40" rows="8" name="textarea-12" id="text-12" class="caseTextArea_h" autocorrect="off"></textarea>
I write many characters on that text area and than close it. Again I open this and it has the same area that was before closing(large area)? How to resize that text area so that it starts with same starting size.
My code:
<div data-role="popup" id="CaseInformationScreen" data-close-btn="none" data-overlay-theme="a" data-dismissible="false">
<div data-role="header" data-theme="b"> Cancel
<h1>Case Information</h1>
Add
</div>
<div data-role="content">
<div>
<img src="img/Documents.png" />
</div>
<div data-role="fieldcontain">
<label for="text-12" style="text-align:top;margin-left: 0px;">Case Name:</label>
<input name="text-12" id="text-12" value="" type="text" class="caseName_h" autocorrect="off">
</div>
<div data-role="fieldcontain">
<label for="caseDate" style="text-align:left;margin-left: 0px;">Case Date:</label>
<input name="caseDate" id="caseDate" value="" type="date" class="caseDate_h">
<!--input name="mydate2" id="mydate2" type="date" data-role="datebox" class="caseDate_h" data-options='{"mode": "calbox","useNewStyle":true,"zindex":1200}'/-->
</div>
<div data-role="fieldcontain">
<label for="textarea-12">Case Notes :</label>
<textarea cols="40" rows="8" name="textarea-12" id="text-12" class="caseTextArea_h" autocorrect="off"></textarea>
</div>
</div>
</div>
Working example: http://jsfiddle.net/Gajotres/7JqRG/3/
Just use this CSS:
#text-12 {
width: 100% !important;
height: 50px !important;
max-height: 50px !important;
}
It will lock textarea height. !important must be used to override default values.
$('#text-12').css('width','whatyouwant');
or
$('#text-12').attr('cols','whatyouwant'); //for the width
$('#text-12').attr('rows','whatyouwant'); //for the height

Programmatically Open a Dialog in JQuery Mobile

I have a single .html file that looks similar to the following:
<div id="myPage" data-role="page">
<div data-role="header">
Back
<h1>My App</h1>
</div>
<div>
<input id="saveButton" type="button" value="Save" onclick="doStuff()" />
</div>
<script type="text/javascript">
function doStuff() {
var updatedText = getUpdatedText();
$("#myMessage", "#myDialog").html(updatedText);
$.mobile.changePage("#myDialog", { role: "dialog" });
}
</script>
</div>
<div id="myDialog" data-role="page">
<div id="myMessage"></div>
<input id="button1" type="button" value="Button 1" data-theme="b" onclick="someJS1();" />
<input id="button2" type="button" value="Button 2" data-theme="c" onclick="someJS2();" />
</div>
When "doStuff()" is called, I want to set a custom message in the text of my dialog and open the dialog. For some reason, I have been unable to open the myDialog. For the life of me, I cannot figure out what I'm doing wrong. I have reviewed the content posted here: http://jquerymobile.com/demos/1.0a4.1/docs/pages/docs-pages.html
I think you need to set the role of the page to dialog
<div id="myDialog" data-role="dialog">
<div id="myMessage"></div>
<input id="button1" type="button" value="Button 1" data-theme="b" onclick="someJS1();" />
<input id="button2" type="button" value="Button 2" data-theme="c" onclick="someJS2();" />
</div>
And then open the dialog with
$.mobile.changePage("#myDialog");
See Fiddle http://jsfiddle.net/kYsVp/2/

JQUERY MObile - How to display collapsible menus inline?

IS there a way to display collapsible menus inline like the way you can make buttons inline
<div data-role="collapsible" data-collapsed="true" data-inline="true">
<h3>Sorting Options</h3>
<div data-role="controlgroup" >
<input type="radio" data-theme="c" name="radio-choice-1" id="datePosted" value="1" onchange='_search.sort("datePosted")'/>
<label for="datePosted">Added</label>
</div>
</div>
<div data-role="collapsible" data-collapsed="true" data-inline="true">
<h3 >Search Options</h3>
<div data-role="controlgroup" >
<input type="radio" data-theme="c" name="radio-choice-1" id="datePosted" value="1" onchange='_search.sort("datePosted")'/>
<label for="datePosted">Added</label>
</div>
</div>
Does anybody know how to make both collapsible buttons show up inline next to each other?
I tried putting data-inline="true" in various places but it does nothing.
MY WORKAROUND SOLUTION
I ended up doing this instead so that buttons show up inline but the menus would show up below both of the buttons. The buttons don't have the +/- change when you click on them but that wasn't as important as having the menus show up in proper place.
$("#showfilteroptions").live('click',function(event) {
$("#searchoptions").hide();
$("#filteroptions").toggle();
});
$("#showsearchoptions").live('click',function(event) {
$("#filteroptions").hide();
$("#searchoptions").toggle();
});
<div data-role="controlgroup" data-type="horizontal" style="text-align: center">
<a href="#" data-role="button" data-icon="plus" data-theme="b" id="showfilteroptions" >Filter</a>
<a href="#" data-role="button" data-icon="plus" data-theme="b" id="showsearchoptions" >Categories</a>
</div>
<div data-role="fieldcontain" id="filteroptions" style="display:none;">
<fieldset data-role="controlgroup" >
<input type="radio" data-theme="c" name="radio-choice-1" id="datePosted" value="1" onchange='_search.sort("datePosted")' />
<label for="datePosted">Added</label>
<input type="radio" data-theme="c" name="radio-choice-1" id="size" value="1" onchange='_search.sort("size")' />
<label for="size">Size</label>
</fieldset>
</div>
<div data-role="fieldcontain" id="searchoptions" style="display:none;">
<fieldset data-role="controlgroup" >
<input type="radio" data-theme="c" name="radio-choice-1" id="all" value="1" onchange='_search.searchCategory(-1)'/>
<label for="all">All</label>
<input type="radio" data-theme="c" name="radio-choice-1" id="oldshows" value="1" onchange='_search.searchCategory(5)'/>
<label for="oldshows">Old Shows</label>
<input type="radio" data-theme="c" name="radio-choice-1" id="newShows" value="1" onchange='_search.searchCategory(7)'/>
<label for="newshows">New Shows</label>
</fieldset>
</div>
Thanks
You could use a grid layout with custom styling:
http://jsfiddle.net/phillpafford/h2kcH/11/ (Working Example)
Inline CSS (will need to play around with this to get the desired look you want):
style="padding-left:5%; width:45%;"
HTML:
<div data-role="page" id="home">
<div data-role="content">
<div class="ui-grid-a">
<div class="ui-block-a" style="padding-left:5%; width:45%;">
<div data-role="collapsible" data-collapsed="true" data-inline="true">
<h3>Sorting Options</h3>
<div data-role="controlgroup" >
<input type="radio" data-theme="c" name="radio-choice-1" id="datePosted" value="1" onchange='_search.sort("datePosted")'/>
<label for="datePosted">Added</label>
</div>
</div>
</div>
<div class="ui-block-b" style="padding-left:5%; width:45%;">
<div data-role="collapsible" data-collapsed="true" data-inline="true">
<h3 >Search Options</h3>
<div data-role="controlgroup" >
<input type="radio" data-theme="c" name="radio-choice-2" id="datePosted2" value="1" onchange='_search.sort("datePosted")'/>
<label for="datePosted2">Added</label>
</div>
</div>
</div>
</div>
</div>
</div>
float:left is your answer. Apply it OUTSIDE the collapsibles. Here is a Fiddle:
http://jsfiddle.net/den232/LDpGe/
Good luck!
.floatleft {
float:left;
}
.floatright {
float:right;
}
.forceinline{ /* Prevent fieldcontain from doing a BLOCK thing */
display:inline !important;
}
.textwidth { /* limit width of input fields */
width:80px;
}
.closespacing { /* controls spacing between elements */
margin:0px 5px 0px 0px;
}
.bigselect { /* centers select with big buttons */
padding: 0px;
margin:2px 5px 0px 0px;
}
.biginputheight { /* matches text input height to big buttons */
padding-top:10px !important;
padding-bottom:12px !important;
}
.miniinputheight { /* matches text input height to minibuttons */
padding-top:5px !important;
padding-bottom:5px !important;
}
<div data-role="page" class="type-home">
<div data-role="content">
<ul data-role="listview">
<li data-role="fieldcontain">first LI line</li>
<li data-role="fieldcontain">
<div class='floatleft closespacing'>
<div data-role="collapsible" data-collapsed="true" data-inline="true" class='floatleft closespacing'>
<h3>Sorting Options</h3>
<div data-role="controlgroup" >
<input type="radio" data-theme="c" name="radio-choice-1" id="datePosted" value="1" onchange='_search.sort("datePosted")'/>
<label for="datePosted">Added</label>
</div>
</div>
<div data-role="collapsible" data-collapsed="true" data-inline="true" class='floatleft closespacing'>
<h3 >Search Options</h3>
<div data-role="controlgroup" >
<input type="radio" data-theme="c" name="radio-choice-1" id="datePosted" value="1" onchange='_search.sort("datePosted")'/>
<label for="datePosted">Added</label>
</div>
</div></div>
</li>
<li data-role="fieldcontain">last LI line</li>
</ul><!-- /listview -->
</div>
</div>

Resources