I have a tabbed toggle statistic page, which has 10 separate tabs that include charts. By clicking each tab, preloaded corresponding chart is being showed up. However, it does not scale into its container. More weird thing is, when I resize the window, visible chart is shown properly (I suppose it does some recalculation thingy). How should I modify my code so that it does that recalculation thingy after a click, or any suggestions on the problem?
Here is my jsfiddle:
http://jsfiddle.net/g66ut7c6/
<!--BEGIN TABS-->
<div class="tabbable tabbable-custom">
<ul class="nav nav-tabs">
<li>
<a href="#tab_1_1" data-toggle="tab">
1
</a>
</li>
<li>
<a href="#tab_1_2" data-toggle="tab">
2
</a>
</li>
<li>
<a href="#tab_1_3" data-toggle="tab">
3
</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="tab_1_1">
<div class="scroller">
<div class="col-md-6 col-md-offset-3">
<div class="portlet light">
<p> Piechart by ülkeler </p>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="tab_1_2">
<div class="scroller">
<div class="col-md-6 col-md-offset-3">
<div class="portlet light">
<p> Piechart by step dağılımı </p>
</div>
</div>
</div>
</div>
<div class="tab-pane" id="tab_1_3">
<div class="scroller">
<div class="col-md-6 col-md-offset-3">
<div class="portlet light">
<p> Piechart by hasta sayısı ay </p>
</div>
</div>
</div>
</div>
</div>
</div>
<!--END TABS-->
Before resize
After a resize, the size is okay
I could not include charts in my jsfiddle because they contain some ruby code.
PS: Using Chartkick and Google Charts to draw charts, and MetronicJS for tabs.
Edit: The first chart that is visible by default is being display properly initially, however others are not. After a resize of a window when another chart is visible, the previous one gets broken again.
You can programmatically fire the 'resize' event:
window.dispatchEvent(new Event('resize'));
Just attach it to the 'click' event that shows the tab.
In your case:
$('div.tabbable > ul > li > a').click( function() {
window.dispatchEvent(new Event('resize'));
});
If your component doesn't resize as respond to the event, you could actually resize the window with:
window.resizeTo(width, height);
UPDATE:
If it is not posible to resize the window (see comments) you could try to redraw the chart when the tab becomes visible. Maybe in that way the chart is able to calculate properly the dimensions it needs to fit in. Something like:
$( 'div.tabbable > ul > li > a' ).click( function() {
myChart.draw( myData );
});
Hope it helps!
Related
I have a navigation that is horizontal. Under every choice I have a div that opens up on click. But the problem is that it binds it's position to the parent navigation button. I want every div that opens on the exact same spot. I want every child div that opens to open from the first element in the navigation bar.
So in this case i want the white open div to bind to "Nyheter" instead. I really can't solve it, I tried set a div element before the navigation that all div that opens binds to in css but it not seems to work.
<div class="Container">
<nav class="NavHorizontal Grid Grid--alignMiddle">
#Navigation.RenderNavigation("master/navigationDesignHeader.cshtml", navigationSettings)
</nav>
</div>
//NavigationDesignheader.cshtml under this line
var elementId = 1;
foreach (var node in nodes)
{
var idElement = "megaMenu" + elementId;
<div class="NavHorizontal-item Grid-cell u-sizeFit" id="#idElement">
<a class="Button Button--tab navigationHeaderLink u-pointer" onclick="toggleMenu('#elementId')">
#node.Name
</a>
#RenderMegaMenu(node.Nodes, node.Link, node.Name)
</div>
elementId++;
}
Megamenu:
<div>
<div id="megaMenuDropdown" class="Container megaMenuDropdown-content displayNone">
<div class="Grid Grid--withGutter">
<div class="Grid-cell u-sizefull u-mt-10">
#nodeName
<div class="megaMenuToggle-closeBars u-pointer" style="float:right">
<span class="megaMenuToggle-closeBar"></span>
<span class="megaMenuToggle-closeBar"></span>
</div>
</div>
</div>
<hr class="colorBlue" />
<div class="Grid Grid--withGutter">
<div class="Grid-cell u-size12of12 u-md-size6of12 u-lg-size6of12">
<ul>
#foreach (var node in firstColumn)
{
<li class="u-mb-10 linkHover">
<a class="userLink colorBlue" href="#node.Link">#node.Name</a>
</li>
}
</ul>
</div>
#if (moreThanTen)
{
<div class="Grid-cell u-size12of12 u-md-size6of12 u-lg-size6of12">
<ul>
#foreach (var node in secondColumn)
{
<li class="u-mb-10 linkHover">
<a class="userLink colorBlue" href="#node.Link">#node.Name</a>
</li>
}
</ul>
</div>
}
</div>
</div>
</div>
Any suggestions?
I'm trying to make an FAQ page using an accordion. In some of the answers I tried to make a clickable link, that will direct you to another question (I don't want the page to refresh).
With what I have now, the opened question (containing the link) will close the accordion after clicking, and open the desired accordion. The only thing missing is that the page will not scroll to the new question.
What I've got:
function openQuestion(q) {
jQuery('.accordion-toggle').removeClass('active');
jQuery('.accordion-container').fadeOut(500);
var accordions = jQuery('.accordion-toggle');
var accordion = accordions[q - 1];
jQuery(accordion).addClass('active');
jQuery(accordion).next('.accordion-container').slideToggle(500);
}
I assume the next jquery line would contain something with scrollIntoView. But no succes yet.
This is what I use in HTML
text
<div class="entry">
<h3>FAQ</h3>
<p>...</p>
<div class="clear"></div>
<div class="accordion wrapper">
<h3 class="accordion toggle active">
...
</h3>
<div class="accordion-container" style="display: block;">
<div class="content-block">
<span style="font-weight: 400;">...</span>
</div>
</div>
<!-- end accordion container -->
<h3 class="accordion toggle">...</h3>
<div class="accordion-container" style="display: none;">...</div>
<!-- end accordion container -->
</div>
</div>
I have 2 pages in my index.html in XDK. I navigate from one to the other. I want to add a back button just like the templates but it's not possible.
This is my html:
<div class="upage vertical-col left" id="mainpage">
<div id="SubPage" class="upage-content vertical-col left ">
<div class="tarea widget uib_w_1 d-margins" data-uib="media/text" data-ver="0" name="uib_w_1">
<div class="widget-container left-receptacle"></div>
<div class="widget-container right-receptacle"></div>
<div class="text-container">
<p>This is the main page</p>
</div>
</div>
<button class="btn widget uib_w_2 d-margins btn-default" data-uib="twitter%20bootstrap/button" data-ver="1" id="buttonSubPage">Go to sub page</button>
</div>
<div id="SubPage2" class="upage-content vertical-col left hidden"><span class="widget uib_w_3 d-margins badge" data-uib="twitter%20bootstrap/badge_and_label" data-ver="1">This is subfile 2</span>
</div>
</div>
I want to add the back button to "SubPage2". How can I achieve this? I'm working with a blank template in the app designer.
Add This code
$(document).ready(function(){
$("#buttonSubPage").click(function(){
$(".text-container").hide();
$("#SubPage2").show();
});
});
See Fiddle
After you add your header to the app designer, switch to the Code view look for the following code in newly created header
<div class="widget-container content-area horiz-area wrapping-col left"></div>
and then add the button code,
<button data-uib="twitter%20bootstrap/button" data-rel="back" data-ver="1" id="back">Back</button>
the data-rel controls the back action, without need for extra javascript.
I just want to add a tooltip to the element which is clicked.
Tooltip is added to all repeat elements when clicked. Please help me.
<div ng-repeat="item in listOfMenu" class="repeat_container">
<div ng-repeat="menu in item" class="repeat_block" ng-click="getTool(menu,menu.pricelist.length)" >
<div class="shadow img_cont">
<img src="{{menu.itemimage}}" class="item_img">
<div ng-repeat="innerItem in menu.pricelist | limitTo:1">
{{innerItem.itemprice}}
</div>
</div>
<div>
{{menu.menuitemname}}
</div>
<div ng-repeat="menu in addToCart" class="add_circle" ng-show="circle">
{{menu.quantity}}
</div>
</div>
</div>
Change the div in:
<div ng-repeat="menu in item" class="repeat_block" ng-click="getTool(menu,menu.pricelist.length)" ng-class="{'clicked': menu.clicked}">
In getTool method
menu.clicked = true;
but you should put clicked:false to all others menu in items
I'm using iScroll for a horizontal, fixed position menu. It works great, however I'm unable to vertically scroll the rest of the page in a mobile browser. It works fine in a pc/mac resized browser window, just not on mobile. I've tried Safari on iPhone and Chrome and Dolphin on Android.
Any ideas how I can get the page to scroll too?
I've played with the vScroll, hScroll, etc options but haven't been able to solve the issue:
<nav id="mainNav">
<ul class="pagesIcons bottom">
<li style="background-color:#000000" class="active selected current youarehere">
<a href="#" class="inner">
<div class="buttonIcon">
<img src="/content/icons/002.png">
</div>
<div class="buttonText">
Homepage
</div>
</a>
</li>
<li style="background-color:#383838" class="">
<a href="#" class="inner">
<div class="buttonIcon">
<img src="/content/icons/002.png">
</div>
<div class="buttonText">
Gallery
</div>
</a>
</li>
<li style="background-color:#5c5c5c" class="">
<a href="#" class="inner">
<div class="buttonIcon">
<img src="/content/icons/004.png">
</div>
<div class="buttonText">
Events
</div>
</a>
</li>
........
</ul>
</nav>
I'm initialising it with:
var myScroll;
function loaded() {
myScroll = new iScroll('mainNav', {
bounce: false
});
}
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
document.addEventListener('DOMContentLoaded', loaded, false);
Solved. I just had to remove:
document.addEventListener('touchmove', function (e) { e.preventDefault(); }, false);
Pretty obvious. This was preventing the default event on 'touchmove'. Durrrrrrr
You can fix this issue by applying this jquery, In place of ClassName you have to add the name of wrapper class in which you want scrolling, If you still face problem let me know I will try to help more.
$('.ClassName').bind('touchmove', function(e){
e.stopPropagation();
});