I have an Owl Carousel inside a tabpanel like this:
<div role="tabpanel" class="tab-pane fade" id="tabAcessorios">
<div id="acessoriosCompativeis8x" class="featured-carousel brand-dot">
//itens here
</div>
</div>
When i click the link to display the tab, the carousel is broken:
I tried to trigger the refresh like this:
$("#acessoriosCompativeis8x").trigger("refresh.owl.carousel");
But it didn't work. What am i missing here?
Here's the nav definition:
<ul class="nav nav-tabs nav-stacked" role="tablist">
<li role="presentation" class="active">FOCO/PRÉ-PAGO</li>
<li role="presentation">INDIVIDUAL</li>
<li role="presentation">FAMÍLIA</li>
<li role="presentation">CONTROLE</li>
#if (Model.AcessoriosCompativeis != null)
{
<li role="presentation">Acessórios Compatíveis</li>
}
</ul>
And here's the carousel definition:
$('#acessoriosCompativeis8x').owlCarousel({
items: 2,
lazyLoad: true,
loop: true,
margin: 10,
autoplay: true,
autoplayTimeout: 5000
});
I managed to solve the issue by destroying and re-creating the carousel when the panel appears:
$('#linkAcessorios').on('shown.bs.tab', function (e) {
var owl = $('#owl-example').owlCarousel(opcoes);
owl.trigger('destroy.owl.carousel');
owl.html(owl.find('.owl-stage-outer').html()).removeClass('owl-loaded');
owl.owlCarousel(options);
});
Related
I'm using ui-boostrap dropdown directive, and want to add my own ng-if to prevent showing it on some cases.
When adding this ng-if, even when it always returns "true" - the dropdown stop working (doesn't pop up). It seems the drop-down button stops receiving ng-click events (therefore not changing the isOpen state..).
HTML:
<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular-animate.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.14.2.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="DropdownCtrl">
<!-- Single button -->
<div class="btn-group" uib-dropdown is-open="status.isopen">
<!-- When putting this ng-if, the drop down stops working -->
<div ng-if="isAllowed()">
<button id="single-button" type="button" class="btn btn-primary" uib-dropdown-toggle ng-disabled="disabled">
Button dropdown <span class="caret"></span>
</button>
<ul class="uib-dropdown-menu" role="menu" aria-labelledby="single-button">
<li role="menuitem">Action</li>
<li role="menuitem">Another action</li>
<li role="menuitem">Something else here</li>
<li class="divider"></li>
<li role="menuitem">Separated link</li>
</ul>
</div>
</div>
<script type="text/ng-template" id="dropdown.html">
<ul class="uib-dropdown-menu" role="menu" aria-labelledby="button-template-url">
<li role="menuitem">Action in Template</li>
<li role="menuitem">Another action in Template</li>
<li role="menuitem">Something else here</li>
<li class="divider"></li>
<li role="menuitem">Separated link in Template</li>
</ul>
</script>
</div>
</body>
</html>
JS:
angular.module('ui.bootstrap.demo', ['ngAnimate', 'ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('DropdownCtrl', function ($scope, $log) {
$scope.items = [
'The first choice!',
'And another choice for you.',
'but wait! A third!'
];
$scope.status = {
isopen: false
};
$scope.toggled = function(open) {
$log.log('Dropdown is now: ', open);
};
$scope.toggleDropdown = function($event) {
$event.preventDefault();
$event.stopPropagation();
$scope.status.isopen = !$scope.status.isopen;
console.log('isOpen = ' + $scope.status.isopen);
};
$scope.isAllowed = function() {
return true;
}
});
Here is a plunker reproduce the problem:
http://plnkr.co/edit/8K9MUsDfFcjyiZvFdv5x?p=preview
Any ideas?
Take out the div with the ng-if on it and put the ng-if on the enclosing div, i.e.
<div class="btn-group" uib-dropdown is-open="status.isopen" ng-if="isAllowed()">
<button id="single-button" type="button" class="btn btn-primary" uib-dropdown-toggle ng-disabled="disabled">
Button dropdown <span class="caret"></span>
</button>
<ul class="uib-dropdown-menu" role="menu" aria-labelledby="single-button">
<li role="menuitem">Action</li>
<li role="menuitem">Another action</li>
<li role="menuitem">Something else here</li>
<li class="divider"></li>
<li role="menuitem">Separated link</li>
</ul>
</div>
I want to use autocomplete and popover in one input tag.
But autocomplete can't display , I see google chrome developer tools, autocomplete is work, just can't display . I don't know how to do .
HTML code
<span class="form-labelTitle img-searchForm02">place</span>
<input class="auto-input" placeholder="city" data-toggle="popover" data-placement="bottom">
<div class="leave-btn"></div>
<div class="autocomplete-div auto1"></div>
<div id="popover-content" class="hide">
<div role="tabpanel">
<ul class="nav nav-tabs arrival-tabs" role="tablist" id="myTab">
<li class="active" role="presentation" ><a href='#JPN' role='tab' data-toggle='tab'>japan</a></li>
<li role="presentation" ><a href='#TPE' role='tab' data-toggle='tab'>taiwan</a></li>
</ul>
<div class="tab-content">
<div class='tab-pane active city' id='JPN'>
<span>Tokyo</span>
<span>okinawa</span>
</div>
<div class='tab-pane' id='TPE'>
<span>taipei</span>
</div>
JS code
$(function(){
$('.auto-input').popover({
'html': true,
'content': function () {
return $('#popover-content').html();
}
});
$('.auto-input').autocomplete({
open:function(event, ui){
$(this).popover('hide');
},
source: [
"tokyo",
"okinawa",
"taipei
],
appendTo:($('.auto1')),
});
});
I have a normal bootstrap navbar with some drop downs on it. When I click on a link in a drop down a modal box appears on screen, when I exit the modal box and then try to click on the drop down again on the navbar it won't work, an orange square border appears around the dropdown as if it can't get focus again or something. Any ideas why this could be happening?
<div class="navbar navbar-inverse navbar-fixed-top ">
<div class="navbar-inner" id="background">
<a class="brand" href="#Url.Action("RssIndex", "Home")">
<img src="~/Images/iconnewzy.png" alt="Newzy" ></a>
<ul class="nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-user"></i>
<label style="display: inline; cursor: pointer;" id="friendsId">Friends</label><b class="caret"></b></a>
<ul class="dropdown-menu">
Add Friend
View Friends
</ul>
</li>
<b style="vertical-align: bottom !important; color: white">Hello, #User.Identity.Name!</b>
#Html.ActionLink("Log off", "LogOff", "Account", routeValues: null, htmlAttributes: new { #class = "btn btn-mini btn-primary" })
</ul>
</div>
</div>
I had the same problem. I've found a workaround in this article. Basically, you have to add this code to your page:
$(function() {
// Setup drop down menu
$('.dropdown-toggle').dropdown();
// Fix input element click problem
$('.dropdown input, .dropdown label').click(function(e) {
e.stopPropagation();
});
});
I've got a slider that's built with jQuery UI Tabs:
<section id="featured">
<aside id="sidebar">
<ul class="ui-tabs-nav">
<li class="ui-tabs-nav-item ui-tabs-selected">
[Tab Heading]
</li>
<li class="ui-tabs-nav-item">
[Tab Heading]
</li>
<li class="ui-tabs-nav-item">
[Tab Heading]
</li>
<li class="ui-tabs-nav-item">
[Tab Heading]
</li>
</ul>
</aside>
<section id="rotate_me">
<div class="featured_panel" id="panel_1">
<p>[Tab Content]</p>
</div>
<div class="featured_panel ui-tabs-hide" id="panel_2">
<p>[Tab Content]</p>
</div>
<div class="featured_panel ui-tabs-hide" id="panel_3">
<p>[Tab Content]</p>
</div>
<div class="featured_panel ui-tabs-hide" id="panel_4">
<p>[Tab Content]</p>
</div>
</section>
<script>$('#featured').tabs('rotate', 4000, false);</script>
The client wants the tabs to rotate through just the first and second tabs.
I added a function to the show event:
.tabs({
show: function(event, ui) {
var selected = $( ".selector" ).tabs( "option", "selected" );
if (selected == 3) {
$( "#featured" ).tabs( "option", "selected", 1 );
}
}
})
but this did nothing.
Any idea how I could make the slider rotate through just the first and second tab?
The selected option only applies to initialization. You could simply trigger a click on the first tab.
$("#featured li.ui-tabs-nav-item:first").trigger("click");
I'm using jQuery mobile RC2. I need to change page from one page to another page without tracking it in history.
I'm using $.mobile.changePage("#searchPage", "pop", false, false);
For Example:
Actual : /DefaultSP.aspx#searchPage
Expected : /DefaultSP.aspx(need to
remove #searchPage in URL)
Thanks in advance.
I'm not sure if they changed the markup on how to use this but here are the Docs:
http://jquerymobile.com/demos/1.0rc2/docs/api/methods.html
JS
//transition to the "confirm" page with a "pop" transition without tracking it in history
$.mobile.changePage( "../alerts/confirm.html", {
transition: "pop",
reverse: false,
changeHash: false
});
Example:
http://jsfiddle.net/MGdm2/10/
JS
$('#customNav').click(function() {
//transition to the "confirm" page with a "pop" transition without tracking it in history
$.mobile.changePage( "#page2", {
transition: "pop",
reverse: false,
changeHash: false
});
});
HTML
<div data-role="page" id="home">
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="f">
<li data-role="list-divider">Home Page</li>
<li><a id="customNav">Page 2 (Click here)</a></li>
</ul>
</div>
</div>
<div data-role="page" id="page2">
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="b" data-dividertheme="e">
<li data-role="list-divider">Page 2 will not be history</li>
<li>Home Page</li>
<li>Page 3 (Click here)</li>
</ul>
</div>
</div>
<div data-role="page" id="page3" data-add-back-btn="true">
<div data-role="header" data-rel="back">
<h1>clicking the back button should go to home page</h1>
</div>
<div data-role="content">
<ul data-role="listview" data-inset="true" data-theme="c" data-dividertheme="f">
<li data-role="list-divider">Page 3 (Click the back button in the header)</li>
<li>Home Page</li>
</ul>
</div>
</div>
so, what's wrong to do
document.location.href = document.location.pathname;