how to create menu and sub menu html from angular with database MySql.
i have table from mysql like this.
id menu
1 master
2 aplikasi
3 laporan
menu.php
<div id='cssmenu'>
<ul>
<li ><a href='#'><span>HOME</span></a></li>
<li class='has-sub'><a href='#'><span>Master</span></a>
<ul>
<li><a ui-sref="user" ui-sref-active="active"><span>User</span></a></li>
<li><a ui-sref="produk" ui-sref-active="active"><span>Produk</span></a></li>
</ul>
</li>
<li class='has-sub'><a href='#'><span>Aplikasi</span></a>
<ul>
<li><a ui-sref="transaksi" ui-sref-active="active"><span>Transaksi</span></a></li>
<li><a ui-sref="stok" ui-sref-active="active"><span>Stok Barang</span></a></li>
</ul>
</li>
<li class='has-sub'><a href='#'><span>laporan</span></a>
<ul>
<li><a ui-sref="itt" ui-sref-active="active"><span>Item terdisplay</span></a></li>
</ul>
</li>
</ul>
</div>
<!-- my app.js-->
var app = angular.module("app",['ui.router']); // jangan lupa kita inject module ui.router
app.config(function($stateProvider, $urlRouterProvider){
$stateProvider
.state("itt",{
url: "/itt",
templateUrl : "modul/itt/itt.php"
})
.state("home",{
url : "/home",
templateUrl : "home.php" // path template
})
.state("user",{
url: "/user",
template : "<h1>Halaman User</h1>"
//controller : "Menu3Ctrl"
})
.state("produk",{
url: "/produk",
template : "<h1>Halaman Produk</h1>"
//controller : "Menu3Ctrl"
})
.state("transaksi",{
url : "/transaksi",
template : "<h1>Halaman Transaksi</h1>"
});
$urlRouterProvider.otherwise("home");
});
i want replace menu in menu.php with my menu in database
Related
$("ol").append("<div id='save' style='display:none'>Save<div>");
$("li").mouseup(function() {
$('#save').show();
});
$("ol").sortable();
$("body").on('click','#save',function(){
$(this).hide();
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js'></script>
<ol id='some123'>Items
<li draggable='true'>Item 1</li>
<li draggable='true'>Item 2</li>
<li draggable='true'>Item 3</li>
<li draggable='true'>Item 4</li>
</ol>
snippet above working correctly with js append.
How to show an element after append by php using mouseup?
So, I have draggable list. And, I need to show element every time the user changes the list order. Every time the element is dropped, I call a function as shown:
$("li").mouseup(function() {
$('#save').show();
});
$("ol").sortable();
When the user clicks save button, I hide it using:
$("body").on('click','#save',function(){
$(this).hide();
})
But how do I make it visible again? $('#save').show(); isn't working!
funniest thing:
my php generate 2 buttons, like that:
<div class="buttons"><button id="saveTit" style="display: none" >Save content</button></div>
<div class="buttons"><button class="butClick" data-con='<?php echo $content?>'>Add new row</button></div>
To call 2nd button i use:
$(".butClick").on('click',function(){
alert($(this).attr('data-tit'));
})
but to call 1st one i have to use body selector... any idea why?!
I change id for class inside div and to call a event...
And it works...
Hi try to change the div to hidden instead and use the prop function instead of show and hide :
$("ol").append("<div id='save' hidden>Save<div>");
$("li").mouseup(function() {
$('#save').prop("hidden",false);
});
$("ol").sortable();
$("body").on('click','#save',function(){
$(this).prop("hidden",true);
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js'></script>
<ol id='some123'>Items
<li draggable='true'>Item 1</li>
<li draggable='true'>Item 2</li>
<li draggable='true'>Item 3</li>
<li draggable='true'>Item 4</li>
</ol>
Hope it helps
Currently i'm using AdminLTE template for my dashboard, but for the second drop down after i click the the second menu, that menu is not stay but it's closing.
When Cascade
After Click
Below is my html code. I'm using codeigniter so i use this anchor for .
<?php if($this->session->userdata('usergroup') == '1' or $this->session->userdata('usergroup') == '4') { ?>
<li class="treeview">
<i class="fa fa-link"></i> <span>Ticketing</span> <i class="fa fa-angle-left pull-right"></i>
<ul class="treeview-menu">
<li><?php echo anchor('Bticketing/Ballticket',"<i class='fa fa-circle-o'></i> All Ticket") ?></li>
<li><?php echo anchor('Bticketingcalendar',"<i class='fa fa-circle-o'></i> Calendar") ?></li>
</ul>
</li>
<?php } ?>
What i want is after i click the all ticket, that menu is stay and show the page. how to do that ?
Note : the default one for active is <li class="treeview active"> but how to make it dynamic to all menu.
Here is code if you want to create active state on AdminLTE menu
var url = window.location;
// for sidebar menu entirely but not cover treeview
$('ul.sidebar-menu a').filter(function() {
return this.href == url;
}).parent().addClass('active');
// for treeview
$('ul.treeview-menu a').filter(function() {
return this.href == url;
}).closest('.treeview').addClass('active');
Hope it will help
use this
<li class="treeview ticketing-tree">
<i class="fa fa-link"></i> <span>Ticketing</span> <i class="fa fa-angle-left pull-right"></i>
<ul class="treeview-menu">
<li><?php echo anchor('Bticketing/Ballticket',"<i class='fa fa-circle-o'></i> All Ticket") ?></li>
<li><?php echo anchor('Bticketingcalendar',"<i class='fa fa-circle-o'></i> Calendar") ?></li>
</ul>
</li>
Add following JQuery code in your page
<script>
$(document).ready(function(){
var href = $(this).attr("href");
var segment = href.substr(href.lastIndexOf('/') + 1);
if(segment == 'Ballticket'){
$('.ticketing-tree').addClass('active');
}
}
</script>
On reference website you can see what you are missing actually...
Here onclick of sub-menu you need to add active class
$(document).ready(function() {
var url = window.location;
// Will only work if string in href matches with location
$('.treeview-menu li a[href="' + url + '"]').parent().addClass('active');
// Will also work for relative and absolute hrefs
$('.treeview-menu li a').filter(function() {
return this.href == url;
}).parent().parent().parent().addClass('active');
});
i am using
<li class="treeview <?php if($page == 'YourPage'){echo 'active';}?>" >
<ul class="treeview-menu">
<li></li>
<li></li>
</ul>
</li>
this is work in my project.
$page is variable from your page displayed.
Here is my site (click here) I 'm trying to get the background image to change on hover of a menu item, and I'm getting close! However, when I hover, the menu disappears and the swap back to the original image is not smooth like I'd like. Any ideas on how I can improve this??
<?php
/*
Template Name: Page - All Projects
*/
?>
<?php get_header(); ?>
<?php
/* #Start the Loop
======================================================*/
if (have_posts()) : while (have_posts()) : the_post();
?>
<?php
/* #Get Fullscreen Background
======================================================*/
$pageimage = get_post_meta($post->ID,'_thumbnail_id',false);
$pageimage = wp_get_attachment_image_src($pageimage[0], 'full', false);
ag_fullscreen_bg($pageimage[0]);
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
//rollover swap images with rel
var img_src = "$pageimage";
var new_src = "";
$(".rollover").hover(function(){
//mouseover
img_src = $(this).attr('src'); //grab original image
new_src = $(this).attr('rel'); //grab rollover image
$(this).attr('src', new_src); //swap images
$(this).attr('rel', img_src); //swap images
},
function(){
//mouse out
$(this).attr('src', img_src); //swap images
$(this).attr('rel', new_src); //swap images
});
//preload images
var cache = new Array();
//cycle through all rollover elements and add rollover img src to cache array
$(".rollover").each(function(){
var cacheImage = document.createElement('img');
cacheImage.src = $(this).attr('rel');
cache.push(cacheImage);
});
})(jQuery);
</script>
<div class="contentarea">
<div id='cssmenu'>
<ul>
<li class='has-sub '><a href='#'>Center Consoles</a>
<ul>
<li class='sub'><a href='http://takeitto11.com/striper2015/portfolio/2oo-cc/'><img class="rollover" width="1500px" height="1000px" rel="http://takeitto11.com/striper2015/wp-content/uploads/2014/10/Striper_HPS_1500x150010.jpg" />200 CC</a></li>
<li class='sub'><a class="220CC" href='#'>220 CC</a></li>
<li class='sub'><a class="2605CC" href='#'>2605 CC</a></li>
</ul>
</li>
<li class='has-sub '><a href='#'>Dual Consoles</a>
<ul>
<li class='sub'><a class="200DC" href='#'>200 DC</a></li>
<li class='sub'><a class="220DC" href='#'>220 DC</a></li>
</ul>
</li>
<li class='has-sub '><a href='#'>Walk Arounds</a>
<ul>
<li class='sub'><a class="200WA" href='#'>200 Walk Around</a></li>
<li class='sub'><a class="220WA" href='#'>220 Walk Around</a></li>
<li class='sub'><a class="2601WA" href='#'>2601 Walk Around</a></li>
<li class='sub'><a class="2901WA" href='#'>2901 Walk Around</a></li>
</ul>
</li>
</div>
<div class="clear"></div>
</ul>
Thank You!!
I wrote my site with php. I have the index file dynamically loading my pages from a pages folder. I have the nav menu in a separate file as well.
so I'm trying to have the text color highlighted when clicked, since I can't get the windowlocation to work. Because of the way I have it setup, the windowlocation returns /index.php with javascript or jquery. So I tried to keep it simple by just targeting the link.
<nav>
<ul>
<li>Home</li>
<li>Skills</li>
<li>About</li>
<li>Contact</li>
</ul>
</nav>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<!--Script to add selected class to highlight active link-->
<script>
$(document).ready(function(){
$("ul li a").click(function(){
$("ul li a").removeClass('selected');
$("ul li a").addClass('selected');
});
});
</script>
my css is setup like this:
a.selected{color:#0066ff;}
I've tried throwing this code in every php file I created. Still nothing works. When I want an alert box to pop up with a message when a link is clicked, that works fine. why does this not work? Nothing changes when I run the code... Any suggestions?
If you reload the page by clicking each link then try
<nav>
<ul>
<li><a href="index.php?p=home" <?php (empty($_GET['p']) || $_GET['p'] == 'home') ? echo 'class="selected"' : ''?> >Home</a></li>
<li><a href="index.php?p=skills" <?php $_GET['p'] == 'skills' ? echo 'class="selected"' : ''?>>Skills</a></li>
<li><a href="index.php?p=about" <?php $_GET['p'] == 'about' ? echo 'class="selected"' : ''?>>About</a></li>
<li><a href="index.php?p=contact" <?php $_GET['p'] == 'contact' ? echo 'class="selected"' : ''?> >Contact</a></li>
</ul>
</nav>
Though you won't need the jQuery function.
If you don't want to reload the page then try this in your jQuery:
$(document).ready(function(){
$("ul li a").click(function(){
$("ul li a").removeClass('selected');
$(this).addClass('selected');
return false;
});
});
$('#menu li a').on('click', function(){
$('li a.current').removeClass('current');
$(this).addClass('current');
});
You need to add selected class in the clicked li element.
try like this:
$(document).ready(function(){
$("ul li a").click(function(){
$(".selected").removeClass('selected');
$(this).addClass('selected');
});
});
Actually you are redirecting when you are clicking in the li element. so jquery wil not be worked in this scenario.
it will work if you use one page application with out page reloading.
You can to do it by php like this:
// index.php
<?php
$page = isset($_REQUEST['p']) ? $_REQUEST['p'] : '';
switch($page) {
case 'skills' :
echo ' <ul>
<li>Home</li>
<li>Skills</li>
<li>About</li>
<li>Contact</li>
</ul>';
break;
case 'about' :
echo ' <ul>
<li><a href="index.php?p=home" >Home</a></li>
<li>Skills</li>
<li>About</li>
<li>Contact</li>
</ul>';
break;
case 'contact' :
echo ' <ul>
<li><a href="index.php?p=home" >Home</a></li>
<li>Skills</li>
<li>About</li>
<li>Contact</li>
</ul>';
break;
default:
echo ' <ul>
<li>Home</li>
<li>Skills</li>
<li>About</li>
<li>Contact</li>
</ul>';
}
I am trying to build a menu for my website and using Smarty to display the pages. When user click on the Logout option the JQuery send an Ajax call to index.php script which contain the code for Smarty to display the page but it is not displaying it. It was working fine before I added the menu. There is no error in the firebug too. Can someone put me in the right direction.
Here is PHP code
if (isset($_POST['menu_index']))
{
if ($_POST['menu_index'] == 'Logout')
{
$smarty->display("login.tpl");
exit;
}
}
Here is JQuery code
$('ul li a').on('click', function() {
var menuItemIndex = $(this).data('val');
console.log(menuItemIndex);
$.ajax({
url: 'index.php',
type: 'POST',
data: {
'menu_index': menuItemIndex
},
dataType: 'json',
success: function(response) {
alert('success');
},
error: function(errorMsg) {
alert('failed');
}
});
});
Here is HTML Code
<form name="mainmenu" id="mainmenu">
<div id='content'>
<div id='jqxMenu'>
<ul>
<li>Maintanence
<ul style='width: 180px;'>
<li>Add Category</li>
<li>Add Sub-category</li>
</ul>
</li>
<li>Process Order
<ul style='width: 180px;'>
<li>Ship Order</li>
<li>Change Order Status</li>
</ul>
</li>
<li>Reports
<ul style='width: 180x;'>
<li>Orders by station</li>
<li>Orders by date</li>
<li>Pending Orders</li>
</ul>
</li>
<li>Logout</li>
</ul>
</div>
</div>
</form>
Hi I think you don't understand how Smarty works, but I can tell you that you don't have any template in html code which is very important for this kind of programming.
You need to make template for menu and call it menu.tpl -> then include it on index.tpl ...
For more informations take a look www.smarty.net