So I am refactoring and redesigning an old application and I have multiple dropdown menus that hold data for people to enter and I would like for there to be a button that when clicked on scrolls to the next one and opens it just to make it easier to get through the form.
My html code looks like this:
<?php foreach loop that adds more dropdowns when entered in through a modal when they click new?>
<button class="tEntry-collapsible-btn tsHeader-collapsible-btn waves-effect"
id="testing"
type="button"
style="background-color: sienna !important;"></button>
<div class="tEntry-collapsible-row>
<div class="tTable-row">
//content to dropdown
</div>
</div>
....usually around 10-15 dropdown menus with the collapsible btn
<?php loop++ ?>
I added a photo for reference, the dropdown buttons are color coordinated and I added a next button at the bottom (minimal styling) and as of right now when the buttons are clicked it drops down fine but I'd also like a button that when clicked i guess focuses the next one and then opens it just for a smoother experience when working your way down the page.
Something like this?
Find the next dropdown and scroll to it with .scrollIntoView().
You would just call the function that drops the dropdown on the next element.
Note: not working well in the snippet... try my codepen
$(function() {
$(document).on('click', '.next', function() {
var el = $(this).closest('.dropdown');
var parent = el.closest('.wrap');
var next = el.nextAll('.dropdown').first();
// scroll like this
// parent.animate({
// scrollTop: next.position().top
// }, 1000);
// or like this; I prefer this one
next[0].scrollIntoView({ behavior: 'smooth', block: 'start' });
});
});
.wrap {
height: 200px;
overflow-y: scroll;
}
.something {
height: 50px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="wrap">
<div class="dropdown">
<ul>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
<button class="next">next</button>
</div>
<div class="something"></div>
<div class="dropdown">
<ul>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
<button class="next">next</button>
</div>
</div>
Related
i am currently working on an drag and drop system.
I would like to add an form that sends the outcome of the dragged boxes(location there currently in set by visitor) to my e-mail. Code is below.
<style type="text/css">
/* show the move cursor as the user moves the mouse over the panel header.*/
#draggablePanelList .panel-heading {
cursor: move;
}
</style>
<!-- Bootstrap 3 panel list. -->
<ul id="draggablePanelList" class="list-unstyled">
<li class="panel panel-info">
<div class="panel-heading">You can drag this panel.</div>
<div class="panel-body">Content ...</div>
</li>
<li class="panel panel-info">
<div class="panel-heading">You can drag this panel too.</div>
<div class="panel-body">Content ...</div>
</li>
</ul>
jQuery(function($) {
var panelList = $('#draggablePanelList');
panelList.sortable({
// Only make the .panel-heading child elements support dragging.
// Omit this to make then entire <li>...</li> draggable.
handle: '.panel-heading',
update: function() {
$('.panel', panelList).each(function(index, elem) {
var $listItem = $(elem),
newIndex = $listItem.index();
// Persist the new indices.
});
}
});
});
All help is welcome!
ineed your help in php &jquery
im working in news site in news blok the image should be chang when a mouse move to defrent news title
this is the templat
<section class="box-nwes-con">
<a href="#">
<img src="images/sport-img.jpg" title="{title}" alt="{title}" />
</a>
<div class="news-box-con">
<div class="title-news-block">{title}</div>
<!-- START BLOCK : text_row -->
<div class="center-news">
<a href="#">
<p>{title}
</p>
</a>
<div class="cler"></div>
</div>
<!-- END BLOCK : text_row -->
</div><!--End news-box-con-->
<div class="cler"></div>
</section>
I new in jquery but i think it's not hard work!!
how i can chang image when hover newstitle
hellllllllllllp pleas
assuming your news title is the in center-news div - please try add this to header.
<script type="text/javascript">
$(document).ready(function() {
$('.center-news p').hover(
function() {
//on mouse enter
$('.box-nwes-con img').prop('src', 'image2.png');
}, function() {
//on mouse out? remove if not needed..
$('.box-nwes-con img').prop('src', 'none.png');
});
});
</script>
Please let me know if you have any difficulty by adding comment and i'll try help more..
UPDATE:
Please see this fiddle:
http://jsfiddle.net/rzQ8f/
I have the following layout
<div id="tabs">
<ul>
<li>Create Username</li>
<li>View Search Logs</li>
<li>Assign Values Table</li>
<li>Edit Values Table</li>
<li>Create Values Table</li>
</ul>
<div id="tabs-1">
<h2>Create Username</h2>
</div>
<div id="tabs-2">
<h2>View Search Logs</h2>
</div>
<div id="tabs-3">
<h2>Assign Values Table</h2>
</div>
<div id="tabs-4">
<h2>Edit Values Table</h2>
</div>
<div id="tabs-5">
<h2>Create Values Table</h2>
</div>
</div>
Each tab has a form in it, when the form is submitted and the page reloads I want the visible tab to still be the tab the user was last on (instead of it going back to the first).
Each form has a hidden field that contains the index of that tab. I then use the below:
<script type="text/javascript">
$(function() {
$("#tabs").tabs({
selected: <?php echo (isset($_POST['selected_tab']) ? $_POST['selected_tab'] : 1)?>
});
});
</script>
This results in showing the right thing e.g
<script type="text/javascript">
$(function() {
$("#tabs").tabs({
selected: 2
});
});
</script>
However the first tab is still the tab that is shown.
$("#tabs").tabs({
selected: 2
});
Should be:
$("#tabs").tabs({
active: 2
});
Tabs uses active property and not selected property.
Also note that the index is base 0, so if you want to select the 2nd tab, your value needs to be 1.
One option would be to include jquery-cookie.js an use tabs like this:
$( "#tabs" ).tabs({
cookie: {
expires: 1
}
});
And this will automatically manage your last open tabs with cookie.
I'm quite sure this has never been asked before.
I am new to jQuery and found jqmPhp very easy to use. However, I am trying to achieve a few things that I find very complicated to implement.
I need to filter list items (like here) and enable the user to check/uncheck several list items to delete. I am trying to implement a similar feature to what Gmail mobile is doing (with a checkbox on the left, where selecting it will make the relevant row highlight and allows users to just click a button to delete checked rows).
Is it possible at all to do that with jqmphp? If so, can anyone assist me with more information, links or code?
I made a Demo for you, by converting list-view into check-able list items.
http://jsfiddle.net/Palestinian/vcXmK/
HTML
<div data-role="page">
<div data-role="header">
<h1>Header</h1>
</div>
<div data-role="content">
<ul id="list-view-test" data-role="listview" data-autodividers="true" data-filter="true" data-inset="true">
<li>Adam Kinkaid
</li>
<li>Alex Wickerham
</li>
<li>Avery Johnson
</li>
<li>Bob Cabot
</li>
<li>Caleb Booth
</li>
<li>Christopher Adams
</li>
<li>Culver James
</li>
</ul>
Delete
Reset
</div>
<div data-role="footer">
<h1>Footer</h1>
</div>
</div>
Code
// Change icons
$('#list-view-test').find('span.ui-icon').each(function () {
if ($(this).hasClass('ui-icon-arrow-r')) {
$(this).removeClass('ui-icon-arrow-r').addClass('ui-icon-checkbox-off');
}
$('#list-view-test').listview('refresh');
});
// toggle "checked/unchecked"
$('#list-view-test').on('click', 'li', function (event) {
event.preventDefault();
$(this).find('span.ui-icon').removeClass('ui-icon-checkbox-off').addClass('ui-icon-checkbox-on');
});
// Delete selected
$('#del').on('click', function () {
$('span.ui-icon').each(function () {
if ($(this).hasClass('ui-icon-checkbox-on')) {
$(this).closest('li').remove();
$('#list-view-test').listview('refresh');
}
});
});
// Clear selection
$('#reset').on('click', function () {
$('span.ui-icon').each(function () {
if ($(this).hasClass('ui-icon-checkbox-on')) {
$(this).removeClass('ui-icon-checkbox-on').addClass('ui-icon-checkbox-off');
}
});
});
I'm having the following scenario. I have a menu and if one hovers over the menu a sub menu appears and if mouse moves out the sub menu disappears, now I want the following if I click on the on a item in the sub menu, I want the sub-menu to remain open, when the new page has been loaded. I'm using superfish Jquery plugin for this.
Is this possible and if how.
my code in html
<div id="nav">
<div id="nav2">
<ul class="sf-menu sf-navbar ">
<li>
<a title="HOME" class="sf-with-ul " href="/index.php?r=site/index&sid=1">HOME</a> </li>
</ul>
<ul class="sf-menu sf-navbar">
<li>
GALLERY
<ul class="subs" id="sub1"><li class="arrow"><img src="images/arrow.gif" /></li><li><a title="Kitchens" href="/index.php?r=images/sddsd&id=1">Kitchens</a></li><li><a title="Vanities" href="/index.php?r=images/sddsd&id=2">Vanities</a></li></ul> </li>
</ul>
<ul class="sf-menu sf-navbar ">
<li>
<a href="?sid=3" class="sf-with-ul " >ACCESSORIES</a>
<ul class="subs" id=""><li class="arrow"><img src="images/arrow.gif" /></li><li><a title="Door Handles" href="/index.php?r=images/sddsd&id=2">Door Handles</a></li><li><a title="Spanners" href="/index.php?r=images/sddsd&id=1">Spanners</a></li></ul> </li>
</ul>
<ul class="sf-menu sf-navbar ">
<li>
<a title="CONTACT US" class="sf-with-ul " href="/index.php?r=site/contact&sid=4">CONTACT US</a> </li>
</ul>
</div>
</div>
and then
the superfish code
$(function(){
$("ul.sf-menu").superfish({
delay: 0,
speed: 'fast',
autoArrows: false,
dropShadows: false
});
});
I've also noticed that the following css code is used to display the item
left: 0;
top: 2.5em;
z-index: 99;
I post a demo for you. Basically I've added a "onHide" function to the superfish function, then some additional coding that keep the menu persistent.
Additional CSS (to default suckerfish.css)
.sf-menu li.sfSelected {
background-color: #CFDEFF;
}
Script
$(function(){
var menu = $("#nav");
menu.find("ul.sf-menu")
.superfish({
delay: 0,
speed: 'fast',
autoArrows: false,
dropShadows: false,
onHide: function(){
if (this.parent().is('.sfPersist')) {
this.show().css('visibility','visible').parent().addClass('sfHover');
}
}
})
.find('li > ul > li').click(function(){
// hide previously persistent children (LOL that just sounds wrong)
menu.find('.sfPersist')
.removeClass('sfPersist sfHover')
.find('> ul').hide().css('visibility','hidden');
// add children that should be persistent
if ($(this).is('.sfSelected')) {
// if previously selected, keep hidden
menu.find('li.sfSelected').removeClass('sfSelected');
} else {
// Hide other selected classes
menu.find('li.sfSelected').removeClass('sfSelected');
// if newly selected, then show
$(this)
.addClass('sfSelected') // remember which one is selected
.parent()
.show().css('visibility','visible')
.parent().addClass('sfHover sfPersist');
}
});
});