How to call two 'on click' events - arcgis

I have a list of districts as well as corresponding Taluks. When I click on a district, it will display a district report in a JQX pie chart. But when I click on Taluks, it will display district reports and sometimes Taluk reports. Currently, I am using this on click events.
$(function () {
$("#menuwrapper ul>li").click(function () {
var districtname = this.id;
GetDistrictReport(districtname);
showresults(districtname);
//alert('Clicked list. ' + a);
});
});
$(function () {
$("#menuwrapper ul>li>ul>li").click(function () {
//var districtname = this.id;
var talukname = this.id;
GetTalukReport(talukname);
showTalukresults(talukname);
//alert('Clicked list. ' + a);
});
});
That menu wrapper id stems from
<div class="ui-layout-east" style="background-color: #bccbde">
<div>
<div style="width: 25%; position: absolute; top: 0px; left: 0px; z-index: 1000">
<ul id="menuwrapper" style="position: absolute; top:-10px; left:-40px;">
<%--<li>--%>
<%--Districts--%>
<ul>
<li id="Bagalkot">Bagalkot
<ul>
<li id="Badami">Badami</li>
<li id="Bagalkot">Bagalkot</li>
<li id="Bilgi">Bilgi</li>
<li id="Hungund">Hungund</li>
<li id="Jamkhandi">Jamkhandi</li>
<li id="Mudhol">Mudhol</li>
</ul>
</li>
<li id="Bangalore">Bangalore
<ul>
<li id="Anekal">Anekal</li>
<li id="Bangalore East">Bangalore East</li>
<li id="Bangalore North">Bangalore North</li>
<li id="Bangalore South">Bangalore South</li>
</ul>
</li>
<li id="Bangalore Rural">Bangalore Rural
<ul>
<li id="Devanahalli">Devanahalli</li>
<li id="Dod Ballapur">Dod Ballapur</li>
<li id="Hosakote">Hosakote</li>
<li id="Nelamangala">Nelamangala</li>
</ul>
</li>
<li id="Belgaum">Belgaum
<ul>
<li id="Athni">Athni</li>
<li id="Belgaum">Belgaum</li>
<li id="Chikodi">Chikodi</li>
<li id="Gokak">Gokak</li>
<li id="Hukeri">Hukeri</li>
<li id="Khanapur">Khanapur</li>
<li id="Parasgad">Parasgad</li>
<li id="Ramdurg">Ramdurg</li>
<li id="Raybag">Raybag</li>
<li id="Sampgaon">Sampgaon</li>
</ul>
</li>

This behavior is because events propagate from child to parent. It would work fine when you would click on District's li, but would show weird behavior when you would click on Taluk's li (because Taluk's li is the child of District's li and the event propagates from Taluk's li to District's li and triggers it).
You should therefore use event.stopPropagation();
$("#menuwrapper").find("ul>li>ul>li").click(function (event) {
if (event.stopPropagation === "function") { event.stopPropagation(); }
var talukname = this.id;
GetTalukReport(talukname);
showTalukresults(talukname);
});

Related

Bootstrap NavTab from Database

I have the following table:
---------------------------
oName Dept
---------------------------
Roo IT
Max MKT
Tom MKT
Then I have the following script on my controller:
ViewBag.GetoName = (from a in _db.TbEmp
where a.Dept == "MKT"
select new {
a.oName
}
).ToList();
I want to load the list above into a navTab on my View. How can I do that? So the navTab bootstrap would be:
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#max">Max</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#tom">Tom</a>
</li>
</ul>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade show active" id="max">
<p>Content1</p>
</div>
<div class="tab-pane fade" id="tom">
<p>Content2</p>
</div>
</div>
Please advice.
Thank you.
If you want oName to be nav_link name,and Dept to be Content.Here is a demo:
<ul class="nav nav-tabs">
#{ var count = 0;}
#foreach (var sample in ViewBag.GetoName)
{
if (count == 0)
{
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="##sample.oName">#sample.oName</a>
</li>
}
else {
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="##sample.oName">#sample.oName</a>
</li>
}
count++;
}
</ul>
<div id="myTabContent" class="tab-content">
#{ var count1 = 0;}
#foreach (var sample in ViewBag.GetoName)
{
if (count1 == 0)
{
<div class="tab-pane fade show active" id="#sample.oName">
<p>#sample.Dept</p>
</div>
}
else
{
<div class="tab-pane fade" id="#sample.oName">
<p>#sample.Dept</p>
</div>
}
count1++;
}
</div>
result:

How can I have a specific tab refreshed on post in Asp.Net Core Razor tabbed pages

I have a tabbed Razor page, on load there is no data to be retrieved from server, active tab set for first tab. However, when I update data on one tab and post it I want the page to get only data for that tab. What I have so far is
<ul class="nav nav-tabs" id="PTWTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="PTW-tab" data-toggle="tab" href="#PTW" aria-controls="ptw" aria-selected="true" style="width:200px">Permit To Work</a>
</li>
<li class="nav-item">
<a class="nav-link" id="HazId-tab" data-toggle="tab" href="#HazId" aria-controls="hazid" aria-selected="false" style="width:200px">Hazard Identification</a>
</li>
<li class="nav-item">
<a class="nav-link" id="GasTest-tab" data-toggle="tab" href="#GasTest" aria-controls="gt" aria-selected="false" style="width:200px">Gas Testing</a>
</li>
<li class="nav-item">
<a class="nav-link" id="IsoCert-tab" data-toggle="tab" href="#IsoCert" aria-controls="isocert" aria-selected="false" style="width:200px">Isolation Certificate</a>
</li>
</ul>
and cshtml is:
public async Task<IActionResult> OnPostIsoCertAsync(int? PTWNo)
{
if (!ModelState.IsValid)
{
return Page();
}
var newIsoCert = await _context.ICContents.FindAsync(PTWNo);
if (newIsoCert == null)
{
return NotFound();
}
if (await TryUpdateModelAsync<ICContent>(
newIsoCert,
"ICContent",
c => c.IdICD,
c => c.IsoStep,
c => c.EquipmentID,
c => c.EquipmentDescription,
c => c.EnSource,
c => c.IsType,
c => c.IsMethod,
c => c.LockNo,
c => c.PreparedBy,
c => c.ImplementedBy,
c => c.VerifiedBy,
c => c.IsStatus))
{
await _context.SaveChangesAsync();
return Page();
}
return Page();
}
there is also an OnGet procedure and html to display data
when I update data on one tab and post it I want the page to get only data for that tab.
If you'd like to just update a specific tab section content, as #Tavershima mentioned, you can try to dynamically render some partial view using Ajax on JavaScript. The following simple demo is for your reference.
#page
#model WebGlobalSearch.MenuTabModel
#{
ViewData["Title"] = "MenuTab";
}
<h1>MenuTab</h1>
<ul class="nav nav-tabs" id="PTWTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="PTW-tab" data-toggle="tab" href="#PTW" aria-controls="ptw" aria-selected="true" style="width:200px">Permit To Work</a>
</li>
<li class="nav-item">
<a class="nav-link" id="HazId-tab" data-toggle="tab" href="#HazId" aria-controls="hazid" aria-selected="false" style="width:200px">Hazard Identification</a>
</li>
<li class="nav-item">
<a class="nav-link" id="GasTest-tab" data-toggle="tab" href="#GasTest" aria-controls="gt" aria-selected="false" style="width:200px">Gas Testing</a>
</li>
<li class="nav-item">
<a class="nav-link" id="IsoCert-tab" data-toggle="tab" href="#IsoCert" aria-controls="isocert" aria-selected="false" style="width:200px">Isolation Certificate</a>
</li>
</ul>
<div class="tab-content">
<div id="PTW" class="tab-pane fade active show">
<h3>Permit To Work</h3>
<br />
<div class="tab-c">
<partial name="PTW" />
</div>
</div>
<div id="HazId" class="tab-pane fade">
<h3>Hazard Identification</h3>
</div>
<div id="GasTest" class="tab-pane fade">
<h3>Gas Testing</h3>
<br />
<div class="tab-c">
<partial name="GasTest" />
</div>
</div>
<div id="IsoCert" class="tab-pane fade">
<h3>Isolation Certificate</h3>
</div>
</div>
#Html.AntiForgeryToken()
#section scripts{
<script>
function UpdateGasTestFunc() {
$.ajax({
type: "POST",
headers: { "RequestVerificationToken": $('input[name="__RequestVerificationToken"]').val() },
url: "MenuTab?handler=UpdateGasTest",
//data: data,
success: function (res) {
$("#GasTest").find("div.tab-c").html(res);
}
});
}
</script>
}
OnPostUpdateGasTest handler
public IActionResult OnPostUpdateGasTest()
{
return Partial("GasTest");
}
Content of partial view GasTest
Gas Testing Page #DateTime.Now.ToString()
<input type="button" value="Update" id="btn_update" onclick="UpdateGasTestFunc()" />
Test Result
I just wanted to avoid javascript and only update the tab that concern me
Under the scenario you described in your question, normally if browser user submit updated data to server without from JavaScript, server would return new response to browser client and full page will be re-rendered, not just a part of html content.
Update:
What I want is to post, refresh page and show the tab I post from
To dynamically reset active tab after page reloaded, you can refer to the following code snippet.
$(function () {
var active_tab_id = localStorage.getItem('activetab');
if (active_tab_id != null) {
//console.log(active_tab_id);
$('#PTWTab a[id="' + active_tab_id + '"]').tab('show');
}
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
//console.log($(e.target).attr("id"));
localStorage.setItem('activetab', $(e.target).attr('id'));
});
})

how to make a conditional multilevel menu with vue.js?

######################## EDIT ########################
According to #Criss's answer, the method did not work, because the child item is different from the parent item.
A simple item without child should look like this:
<li class="sidebar-item">
<a class="sidebar-link" href="/test.html">
<span class="align-middle">Test</span>
</a>
</li>
When an item has a child it should have the option data-toggle="collapse"
<li class="sidebar-item">
<a class="sidebar-link" href="/test.html" data-toggle="collapse" >
<span class="align-middle">Test</span>
</a>
<ul class="sidebar-dropdown list-unstyled collapse">
##<li>#### CHILD ITENS ####</li>##
</ul>
</li>
And the subitems when they do not have more childs should look like this:
<li class="sidebar-item">
<a class="sidebar-link" href="/test3.html">Test3</a>
</li>
my new attempt based on #Criss's response, went like this:
Vue.component('menu-item', {
props: ['cmitens'],
template: '#menu-item'
});
new Vue({el: '#vuesadminmenu',
data: {
menuitens: {"test0":{"titulo":"Test0","open":"false","selected":"false","link":"http:\/\/www.link.com\/test0","child":""},"test1":{"titulo":"Test1","open":"true","selected":"false","link":"http:\/\/www.link.com\/test1","child":{"test2":{"titulo":"Test2","open":"true","selected":"false","link":"http:\/\/www.link.com\/test2","child":{"test3":{"titulo":"Test3","open":"true","selected":"true","link":"http:\/\/www.link.com\/test3","child":""}}},"test4":{"titulo":"Test4","open":"false","selected":"false","link":"http:\/\/www.link.com\/test4","child":""}}},"test5":{"titulo":"Test5","open":"false","selected":"false","link":"http:\/\/www.link.com\/test5","child":{"test6":{"titulo":"Test6","open":"false","selected":"false","link":"http:\/\/www.link.com\/test6","child":""}}},"test7":{"titulo":"Test7","open":"false","selected":"false","link":"http:\/\/www.link.com\/test7","child":""}}
}
});
ol ol, ol ul, ul ol, ul ul { margin-left: 20px; }
<script src="https://appstack.bootlab.io/js/app.js"></script>
<link href="https://appstack.bootlab.io/css/app.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<div class="wrapper">
<nav class="sidebar">
<div class="sidebar-content">
<ul id="vuesadminmenu" class="sidebar-nav">
<template id="menu-item">
<li class="sidebar-item" v-for="(mitem, mkey) in menuitens" v-bind:class="[(mitem.open == 'true') ? 'active' : '']">
<a class="sidebar-link" v-bind:href="mitem.child !== '' ? '#'+mkey : mitem.link" :data-toggle="[(mitem.child !== '') ? 'collapse' : '']" v-bind:class="[(mitem.open == 'true') ? '' : 'collapsed']">
<span class="align-middle">{{mitem.titulo}} {{mitem.open}}</span>
</a>
<ul class="sidebar-dropdown list-unstyled collapse" v-if="mitem.child !== ''" v-bind:class="[(mitem.open == 'true') ? 'show' : '']">
<menu-item :cmitens="mitem.child"></menu-item>
</ul>
</li>
</template>
</ul>
</div>
</nav>
</div>
But the subitems are still disappearing.
######################## QUESTION ########################
I try to make a multilevel menu
In vue.js I only get the first level. I have no idea how to do the loop for all levels, and treat the conditions of when it is a fixed item or item with child.
I'm trying to do so:
--> moved to the above edition <--
I have this multidimensional json
{"test0":{"titulo":"Test0","open":"false","selected":"false","link":"\/test0.html","child":""},
"test1":{"titulo":"Test1","open":"false","selected":"false","link":"\/test1.html"","child":{
"test2":{"titulo":"Test2","open":"false","selected":"false","link":"\/test2.html"","child":{
"test3":{"titulo":"Test3","open":"false","selected":"false","link":"\/test3.html"","child":""}}},
"test4":{"titulo":"Test4","open":"false","selected":"false","link":"\/test4.html"","child":""}}},
"test5":{"titulo":"Test5","open":"false","selected":"false","link":"\/test5.html"","child":{
"test6":{"titulo":"Test6","open":"false","selected":"false","link":"\/test6.html"","child":""}}},
"test7":{"titulo":"Test7","open":"false","selected":"false","link":"\/test7.html"","child":""}}
I'd like to do something like this:
ol ol, ol ul, ul ol, ul ul {
margin-left: 20px;
}
<script src="https://appstack.bootlab.io/js/app.js"></script>
<link href="https://appstack.bootlab.io/css/app.css" rel="stylesheet"/>
<div class="wrapper">
<nav class="sidebar">
<div class="sidebar-content">
<ul class="sidebar-nav">
<li class="sidebar-item">
<a class="sidebar-link" href="/test0.html">
<span class="align-middle">Test0</span>
</a>
</li>
<li class="sidebar-item active">
<a href="/test1.html" data-toggle="collapse" class="sidebar-link">
<i class="align-middle" data-feather="layout"></i> <span class="align-middle">Test1</span>
</a>
<ul class="sidebar-dropdown list-unstyled collapse show">
<li class="sidebar-item active">
<a href="/test2.html" data-toggle="collapse" class="sidebar-link">
<i class="align-middle" data-feather="layout"></i> <span class="align-middle">Test2</span>
</a>
<ul class="sidebar-dropdown list-unstyled collapse show">
<li class="sidebar-item">
<a class="sidebar-link" href="/test3.html">Test3</a>
</li>
</ul>
</li>
</ul>
</li>
<li class="sidebar-item">
<a class="sidebar-link" href="/test4.html">
<span class="align-middle">Test4</span>
</a>
</li>
</ul>
</div>
</nav>
</div>
Can someone help me how can I do the other levels??
Vue.component('menu-item', {
props: ['menuitens'],
template: '<ul class="sidebar-nav">'+
'<li class="sidebar-item" v-for="(mitem, mkey) in menuitens" v-bind:class="[(mitem.open == \'true\') ? \'active\' : \'\']">'+
'<a class="sidebar-link" v-bind:href="mitem.link">'+
'<span class="align-middle">{{mitem.titulo}} {{mitem.open}}</span>'+
'</a>'+
'<menu-item v-if="mitem.child !== \'\'" :menuitens="mitem.child"></menu-item>'+
'</li>'+
'</ul>'
});
new Vue({el: '#vuesadminmenu',
data: {
menuitens: {"test0":{"titulo":"Test0","open":"false","selected":"false","link":"http:\/\/www.link.com\/test0","child":""},"test1":{"titulo":"Test1","open":"true","selected":"false","link":"http:\/\/www.link.com\/test1","child":{"test2":{"titulo":"Test2","open":"true","selected":"false","link":"http:\/\/www.link.com\/test2","child":{"test3":{"titulo":"Test3","open":"true","selected":"true","link":"http:\/\/www.link.com\/test3","child":""}}},"test4":{"titulo":"Test4","open":"false","selected":"false","link":"http:\/\/www.link.com\/test4","child":""}}},"test5":{"titulo":"Test5","open":"false","selected":"false","link":"http:\/\/www.link.com\/test5","child":{"test6":{"titulo":"Test6","open":"false","selected":"false","link":"http:\/\/www.link.com\/test6","child":""}}},"test7":{"titulo":"Test7","open":"false","selected":"false","link":"http:\/\/www.link.com\/test7","child":""}}
}
});
ol ol, ol ul, ul ol, ul ul { margin-left: 20px; }
ul {
padding-bottom: 0 !important;
}
<script src="https://appstack.bootlab.io/js/app.js"></script>
<link href="https://appstack.bootlab.io/css/app.css" rel="stylesheet"/>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<div class="wrapper">
<nav class="sidebar">
<div class="sidebar-content" id="vuesadminmenu">
<menu-item :menuitens="menuitens"></menu-item>
</div>
</nav>
</div>
This works by using recursion - you define a component that holds it's own link and all child links and v-if="menuitem.child" exists, then the component creates a sub-copy of itself.
The beautiful thing about this approach is that you no longer care how deeply nested the child items are.
You should tweak the styling tho...

Hover on Navbar Social Icons

I can get the hover effect of the icon over just the font awesome, but not over the complete separate elements. And I want each element to have its original color on hover.
how can I get the right hover effect?
Here is the HTML Code used
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right socialnav">
<li class="twitternav"><i class="fa fa-twitter"></i></li>
<li class="facebooknav"><i class="fa fa-facebook"></i></li>
<li class="instagramnav"><i class="fa fa-instagram"></i></li>
<li class="youtubenav"><i class="fa fa-youtube"></i></li>
<li><i class="fa fa-envelope"></i></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="active">Home</li>
<li>About Us</li>
<li>Our Services</li>
<li>BODY SCULPTING</li>
<li>Clinical</li>
<!--<li>Testimonials</li>-->
<li>Gallery</li>
<li>PROMOTIONS</li>
<li>Team</li>
<li>Contact</li>
</ul>
And here is the CSS code that I have tried.
.navbar-right .socialnav > li .facebooknav a:hover {
color: #4060A5 !important;
}
.social .fa-twitter:hover {
color: #00ABE3;
}
.social .fa-instagram:hover {
color:#517fa4;
}
.social .fa-youtube:hover {
color:#C31A1E;
}
The website is http://www.hardyhealth.com/ (top bar social media icons)
Any help would be awesome thank you!!!
Try .twitternav:hover .fa { color: #yourcolor; }. And so on.

Make bootstrap "dropdown" expand to the side of the button

I'm building a site using the Bootstrap (3.2.0) and I have a button on my page that I'd like to trigger a "dropdown" menu style effect however instead of having the menu expand downward from the button I'd like it to slide out of the right side. The "dropdown" menu items would still be stacked vertically just like normal but instead of having the top of the menu connected to the bottom of the button, the upper-left side of the menu would be connected to the upper-right side of the button.
sounds like a great idea is an example of a side by side nav, i found on the net. http://www.bootply.com/uBVgiR9DDd
.dropdown-menu.multi-column {
width: 400px;
}
.dropdown-menu.multi-column .dropdown-menu {
display: block !important;
position: static !important;
margin: 0 !important;
border: none !important;
box-shadow: none !important;
}
<ul class="nav">
<li class="dropdown"> <a class="" href="#" data-toggle="dropdown">Dropdown Heading</a>
<div class="dropdown-menu multi-column">
<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
<ul class="dropdown-menu">
<li><a class="" href="#">Col 1 - Opt 1</a>
</li>
<li><a class="" href="#">Col 1 - Opt 2</a>
</li>
</ul>
</div>
<div class="span6">
<ul class="dropdown-menu">
<li><a class="" href="#">Col 2 - Opt 1</a>
</li>
<li><a class="" href="#">Col 2 - Opt 2</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</li>
</ul>