Let's say I have a jQuery Mobile site with a bunch of <li>
with a split icon (data-icon="grid"
).
Is it possible to have the left-hand side of the list item not wrapped in a href
but keep the button on the right-hand side?
Example: http://jsfiddle.net/SSQMB/
I have tried:
$(selection).contents().unwrap();
And this works, it removes the link as requested (and fixes the problem I've outlined below), but it goes and breaks a whole bunch of the layout and styling on the list item.
The issue I'm trying to resolve is this:
<li>
items on a page<li>
might have a <select>
element in it with 5-10 options.<select>
everything works finedata-role="none"
on the <select>
elements makes the page fast and workable again<select>
, the link from behind the <select>
is triggered and the <select>
box is cancelledAny ideas?
OK, after delving through the stock jQuery Mobile CSS, I found the styles that determine the formatting for the <li>
. I duplicated these in a seperate stylesheet and made them apply to a <span>
instead of an <a>
:
.ui-li .ui-btn-text span.ui-link-inherit { text-overflow: ellipsis; overflow: hidden; white-space: nowrap; } .ui-li .ui-btn-inner span.ui-link-inherit { padding: .7em 15px .7em 15px; display: block; }
Then, set up the <li>
as such:
<li data-icon="grid">
<a href="#" onclick="return false;" class="leftLink">
<span class="ui-link-inherit">
.... content ....
</span>
</a><a href="#"> ... </a>
</li>
Then some jQuery:
$('.leftLink').parent().parent().parent().removeClass('ui-btn');
$('.leftLink').contents().unwrap();
and Voila: http://jsfiddle.net/Zwhs3/2/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With