Navbar buttons stay pressed - jquery-mobile

I am using two
<li><a href="#" type="button" > text</a></li>
type buttons in the footer navbar of my application, to trigger functions in my application (not for navigation.). After each press the button stays pressed, until another button in the navbar is pressed. How can I avoid this behavior?

Another way to handle this is to return false from your event binding so that JQM doesn't add the class in the first place.

Remove manually class ui-btn-active from the last pressed button.
$('#button_id').removeClass('ui-btn-active');
EDITED
The best way is to redefine styles for class ui-btn-active, the same as for the 'unclicked' button. For example:
.ui-footer .ui-navbar .ui-btn-active {
border: 1px solid #222;
background: #333333;
font-weight: bold;
color: #fff;
text-shadow: 0 -1px 1px #000;
background-image: -webkit-gradient(linear, left top, left bottom, from( #555), to( #333));
background-image: -webkit-linear-gradient(#555, #333);
background-image: -moz-linear-gradient(#555, #333);
background-image: -ms-linear-gradient(#555, #333);
background-image: -o-linear-gradient(#555, #333);
background-image: linear-gradient(#555, #333);
}​
Example here.

<button type="button" class="btn btn-default touchbtn">Test</button>
$('.touchbtn').bind('touchstart', function() {
$(this).css('background-color', 'black');
});
$('.touchbtn').bind('touchend', function() {
$(this).css('background-color', 'white');
});

Related

MVC Button click open in new Window

Hi I need to open my view in a new window on this button click but it opens in the same window. This is the syntax I'm using.
<button id="btnPrintReport" onclick="location.href='#Url.Action("LoadReports", "DashBoard", new { target="_blank" })'" >Print</button>
Have I missed anything? Thanks.
Try window.open to open link in a new tab
onclick="window.open('#Url.Action("LoadReports", "DashBoard", new { target="_blank" })')"
DEMO
As far as I know, <button> won't work with target. Same goes for input type="button" ... /> elements:
You need to use an anchor and style it with css as a button
Print
<!--taken from http://stackoverflow.com/questions/2187008/styling-an-anchor-tag-to-look-like-a-submit-button-->
.button {
text-decoration: none; font: menu;
display: inline-block; padding: 2px 8px;
background: ButtonFace; color: ButtonText;
border-style: solid; border-width: 2px;
border-color: ButtonHighlight ButtonShadow ButtonShadow ButtonHighlight;
}
.button:active {
border-color: ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
}

With jQuery-Mobile, how to insert icon into table cell

In the example
http://jsfiddle.net/yotam/n2mfy3hg/
there is a table with an anchor alert-button inside a table-cell.
<span>
<a id="aimg" href="#" data-inline="true"
class="ui-btn ui-btn-inline ui-icon-search ui-btn-icon-notext"></a>
</span>
How can one have this 'alert' icon simply inserted in a table-cell,
without neither an anchor nor a button, thus
avoiding the unnecessary <a>-markup and undesired hover effect?
You can use a simple span with a couple of CSS rules to position it correctly for a jQM icon
<span class="ui-icon-alert ui-btn-icon-notext inlineIcon"></span>
.inlineIcon {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
If you prefer the icon to be dark without the gray circle behind it:
<span class="ui-alt-icon ui-icon-alert ui-btn-icon-notext inlineIconNoDisk"></span>
.inlineIconNoDisk {
display: inline-block;
position: relative;
vertical-align: middle;
margin-right: 6px;
}
.inlineIconNoDisk:after {
background-color: transparent !important;
}
Here is your updated FIDDLE (both options are shown)

How do you change the background color of a jquery mobile list view 1.40?

I'm having trouble changing the background on a list view in jqm... I can't change it to tranparent. What is the jqm class inheritance structure for this?
I had a lot of problems with this. There are some high level class inheritances to overcome and they are not easily found. Here is an example with jquery mobile 1.40. This is a sample allowing you to create a fully custom listview.
The trickiest ones are the ones that deal with the first-child and the button li.ui-first-child a.ui-btn - it took me a few hours to track this done. Hopefully this helps others as 1.40 is now final.
The following example is a very common necessity creating a custom menu on an overlay panel.
<ul data-role="listview" class="primary-menu">
<li data-icon="false">
<a href="#product" class="ui-btn ui-nodisc-icon ui-btn-icon-left ui-icon-myicon" >
View Products </a>
</li>
</ul>
/* Menu Classes */
.ui-btn-close-panel {
background-color:#b4316c !important;
}
ul.primary-menu {
margin-top:10px;
border-top:none;
}
ul.primary-menu li a{
font-size: 1em;
line-height: 1.3;
color:#ffffff !important;
font-family: 'ramblabold', Arial, sans-serif;
background-color:transparent !important;
border-bottom:1px solid #f2e3ea !important;
background-image:none !important
}
ul.primary-menu.ui-listview li.ui-first-child a.ui-btn {
color:#ffffff !important;
background-color:transparent !important;
border-bottom:1px solid #f2e3ea !important;
background-image:none !important
}
ul.primary-menu.ui-listview li a.ui-btn {
color:#ffffff !important;
background-color:transparent !important;
border-bottom:1px solid #f2e3ea !important;
background-image:none !important
}

How to make one side of a div pointy with CSS?

I'm trying to create a pointy button like this:
So far, I was only able to achieve this:
I thought increasing the horizontal border-radius would make it sharp, but all it does it make the roundness longer.
HTML
<a class="button">Back</a>
CSS
.button {
display: inline-block;
height: 3em;
padding: 0 0.7em 0 1.4em;
border: 0.1em solid black;
border-radius: 3em 0.4em 0.4em 3em / 1.5em 0.4em 0.4em 1.5em;
background: -moz-linear-gradient(
top,
#fff,
#ccc
);
}
You don't want to be using border-radius as that assigns a quarter-circle shape to each specified corner. Instead you hack it with specific border-width properties, as illustrated in this site: http://www.howtocreate.co.uk/tutorials/css/slopes
However I feel you're solving the problem the wrong way; what you're doing is best done using a background image, which is how the iOS-style Back buttons are implemented in iPhone-for-web stylesheets. If you need something resolution-independent then you can use SVG without penalty now.
Having thought about it more, this is a more elegant solution that allows much more effective styling and the use of just one HTML element. Using this method, we can achieve the results in your concept completely.
HTML
Back
CSS
a.button {
text-decoration:none;
color:#111;
text-shadow:0 1px 0 #fff;
font-weight:bold;
padding:10px 10px;
font-size:14px;
border-radius:0 8px 8px 0;
-webkit-border-radius:0 8px 8px 0;
float:left;
margin-left:30px;
margin-top:20px;
position:relative;
font-family:verdana;
color:#3b3d3c;
border:1px solid #666;
border-left:0;
background: -moz-linear-gradient( top , #eee 0%,#bbb 100%);
background: -webkit-linear-gradient( top , #eee 0%,#bbb 100%);
}
a.button:after {
content:"";
width:25px;
height:25px;
background: -moz-linear-gradient( left top , #eee 0%,#bbb 100%);
background: -webkit-linear-gradient( left top , #eee 0%,#bbb 100%);
-moz-transform: rotate(45deg);
-webkit-transform: rotate(45deg);
display:block;
position:absolute;
top:5px;
left:-14px;
z-index:-1;
border:1px solid #666;
}
#media screen and (-webkit-min-device-pixel-ratio:0) {
a.button:after{
border-left:0;
left:-13px;
}
The last rule is for Chrome, which otherwise renders the result slightly differently.
Hope this helps.
You can create such an effect using 2 elements side by side wrapped in the anchor tags.
<style type="text/css">
.arrow-left {
width:0;
height:0;
border-top:30px solid transparent;
border-bottom:30px solid transparent;
border-right:30px solid orange;
float:left;
}
.button {
float:left;
height:60px;
background:orange;
width:50px;
line-height:60px;
font-weight:bold;
border-top-right-radius:8px;
border-bottom-right-radius:8px;
}
</style>
</div><div class="button">Back</div>
I'm not sure if it's the most refined solution, but it certainly looks the same as your concept art and functions as intended.

Problem with jquery draggable and div with bottom fix position

I have a problem with a div that at the begin is fixed in the bottom-left corner. I need to do it draggable but when I use jquery to do it the bottom position remains and the size of the div changes.
You can see the behavior in this page: http://paraguasparados.com
The div css code is:
.fcp-cpanel{
position:fixed;
bottom:20px;
left:10px;
z-index: 99999;
padding: 5px;
color: #000;
text-align: left;
font-size: 11px;
background:url('../img/blueicons/background.jpg') repeat-x;
border:1px solid #000;
}
The jquery code is:
$jn("#fcp-cpanel").draggable({
containment:"body",
scroll: false,
opacity: 0.35
});
When in firebug I remove the 'bottom' css style it works like it should.
Thanks for any help.
The easiest solution to this is to add a width and height to your fixed draggable <div> to stop it from resizing on drag.
The problem is that you are making a fixed element draggable and so the bottom css attribute is messing it up when you start moving it. A fix for this is to create a container div that has the fixed css attributes and inside you can add the draggable element. Something like this:
css:
.fcp-cpanel-container{
position:fixed;
bottom: 10px;
left:10px;
}
.fcp-cpanel{
padding: 5px;
color: #000;
text-align: left;
font-size: 11px;
background:url('http://paraguasparados.com/modules/mod_friendchatppd/img/blueicons/background.jpg') repeat-x;
border:1px solid #000;
}
html:
<div class="fcp-cpanel-container">
<div class="draggable fcp-cpanel">
<p><b>Amigos Online</b>
<span id="onlusers" class="onlusers">0</span><span onclick="register()"><img title="Registrar" alt="Registrar" src="http://paraguasparados.com//modules/mod_friendchatppd/img/blueicons/visible.jpg"></span>
<span onclick="maximize()" id="fcp-micon">
<img title="Maximizar" alt="Maximizar" src="http://paraguasparados.com//modules/mod_friendchatppd/img/blueicons/max.jpeg">
<img style="display:none;" title="Minimizar" alt="Minimizar" src="http://paraguasparados.com//modules/mod_friendchatppd/img/blueicons/min.jpeg">
</span>
</p>
</div>
</div>
I set up a working example with your code here: http://jsfiddle.net/NdUNu/.
I tried this and it did what I wanted
$(function() {
$("#draggable").draggable({ containment: "window" });
});

Resources