I have modified the jquery accordion to show more than one opened divs like this:
$(function() {
var icons = {
header: "ui-icon-circle-arrow-e",
headerSelected: "ui-icon-circle-arrow-s"
};
jQuery('#accordion').accordion({
icons: icons,
collapsible: true,
active: false,
autoHeight: false,
navigation: true,
disabled: true });
jQuery('#accordion h3.ui-accordion-header').click(function() {
jQuery(this).next().slideToggle();
});
});
It works fine except one thing that when I click any header, It expands but arrow on header doesn't change.
I followed following link:
http://sammybrent.inelsternwick.com/blog/?p=30
Please suggest solution.
Basically, you're trying to mimic the accordion-behaviour. But on a click, that's not everything the accordion does. It changes the classes of the arrow and the headers too, which changes the picture.
So what you could do to get the arrows right is to change the class from ui-icon-circle-arrow-e to ui-icon-circle-arrow-s and vice versa if the header is clicked. Adding something like:
$(this).find('.ui-icon').toggleClass('ui-icon-circle-arrow-e ui-icon-circle-arrow-s');
would work I guess. I don't think using the accordion like this is a very good solution btw.
Related
I'm trying to create a more custom dropdown for adding all the toolbar buttons under it when toolbarXS is activated (all the missing icons in the XS should be under the more dropdown.
unfortunately the docs aren't that clear and outputting only text options which does nothing besides showing.
i was wondering if anybody could help in how to do it.
i.e
// define annotation button for imagePopup
$.FroalaEditor.DefineIcon('annotationIcon', { NAME: 'pencil'}); // the icon
$.FroalaEditor.RegisterCommand('annotation', { // the button
title: 'Annotation',
icon: 'annotationIcon',
undo: true, // Save the button action into undo stack.
focus: true, // Focus inside the editor before the callback.
showOnMobile: true, // Show the button on mobile or not.
refreshAfterCallback: true, // Refresh the buttons state after the callback.
// Called when the button is hit.
callback: function () {
annotateImage(this);
}
})
// Define `more` dropdown button.
$.FroalaEditor.RegisterCommand('moreDropdown', {
title: 'More',
icon: 'More',
undo: true,
focus: true,
type: 'dropdown',
options: {
"annotation": 'annotation'
},
});
Thanks in advance
EDIT:
the only way i could figure out now is to use
html: function() {
return 'HTML_CODE'
}
and just write all the ul by myself which is disgusting and doesn't seem like the proper way of doing it.
Any help will be appreciated.
After talking with froala guys!
Custom popup
is a solution for implementing a popup with toolbar buttons as a dropdown.
Thanks
I have a html file whose skeleton is as follows:
<div id ="QBForm">
<h3>Query1</h3>
<div class ="QBSubForm">...</div>
</div>
I have a "AddQuery" button and on clicking that, I want to add another subform to the existing form and here's how I do that:
$("#AddQuery").click(function (event) {
var querysubform = $(".QBSubForm").html();
$("<h3>Query2</h3>" + querysubform).appendTo("#QBForm");
});
And I have this in my jQuery Ready() function:
$("#QBForm").accordion();
But every time, I click on my add query button, the subform is added but it is not collapsible, its just its own static thing.
How do I add a sub-form and make each sub-form collapsible?
You should try passing accordion with active: false and collapsible: true.
I haven't really tested the code below, but try:
$("#QBForm").accordion({ active: false, collapsible: true });
if you do not set collapsible to true, jQuery UI will set at least one section open.
Use refresh method of accordion to include dynamically added content.
Then if you want the new section opened you could also set the last panel to active by using -1 as index
$("#AddQuery").click(function (event) {
var querysubform = $(".QBSubForm").html();
$("<h3>Query2</h3>" + querysubform).appendTo("#QBForm");
/* only refresh*/
$("#QBForm").accordion('refresh');
/* refresh and set new panel active */
$("#QBForm").accordion('refresh').accordion( "option", "active", -1 );;
});
Accordion Refresh docs()
I have two Swipers on a page, which are linked and synchronized. Both are looped and show some 60 slides or so (length is dynamic). Both Swipers have pagination and it works fine on both a click on 'next' and 'previous' button (.swipePrev() and .swipeNext()).
The first Swiper is showing just one big image, the second one is a carousel with thumbnails (showing the active one, and two previous and two next slides). When I page on either one, the active index is updated and the active slide is centered in the small one, the big image is updated too.
I now want to add functionality to also update both sliders when I click on a slide in the carousel. I added the following code to the carousel:
onSlideClick: function() {
accoPager.swipeTo(accoPager.clickedSlideIndex);
accoSlider.swipeTo(accoPager.activeIndex);
}
This works fine when I click it once, but on a second click it doesn't work anymore.
Fun thing, after I use the regular pagers (the arrow buttons on either side), or I slide, the events work again. What seems to be happening is that the active index is not updated properly when I use .swipeTo(), but it is corrected when I use .swipeNext() or .swipePrevious().
The initialization of the Swipers is (big one first):
slider= $('#acco-slider-top').swiper({
mode: 'horizontal',
paginationClickable: true,
slidesPerView: 'auto',
loop: true,
loopedSlides: 99,
onTouchEnd: function () {
pagerCarousel.swipeTo(slider.activeIndex);
}
});
pagerCarousel = $('#pager-area .swiper-container').swiper({
mode: 'horizontal',
paginationClickable: true,
slidesPerView: 'auto',
offsetPxBefore: 144,
loop: true,
loopedSlides: 99,
onTouchEnd: function () {
slider.swipeTo(pagerCarousel.activeIndex);
},
onSlideClick: function() {
pagerCarousel.swipeTo(pagerCarousel.clickedSlideIndex);
slider.swipeTo(pagerCarousel.clickedSlideIndex);
}
});
I tried setting the active index, but that doesn't work. When I alert anything in the onSlideClick event I found that the event is still linked to the Swiper, but it gets stopped somewhere in the swiper code.
Does anyone have any issues with this too and what's the best way to proceed? I think it has something to do with the params.onSlideClick _this.allowSlideClick toggles in the Swiper code, but I can't pinpoint what exactly.
EDIT: Not unimportantly, I'm using Swiper 2.4.2+
This should work, hard to say where is the problem without looking at live example. Check this example and how it is done here, maybe it will be helpful http://goo.gl/Nc2M5P
My designer put a bxslider to scroll through 3 divs nicely on my page.
When the page runs, in the html I see it generates 6 divs on the page. It shows div 3, div2, div1, div3, div2, div1.
Just because the duplicated fields on my page now mess up my programing.
Is that neccesary, and is there any way I can touch the code that it shouldn't duplicate my divs?
The page is full of complex code , with an ajax passing the data-serialize to a post form.
Becuase it's all duplicated, now all fields are coming through as 'value,value'. Therefore it's not giving me accurate respones, and well as undefined when it's supposed to be numeric.
My form posts looks like this:
function submitCart () {
$.post(
"scripts/savecart.asp",
$("#form1").serialize()
);}
How could I add that not bx- to it?
As commented in the source code of bxSlider:
if infinite loop, prepare additional slides
So I was able to fix this by adding infiniteLoop: false to the config object:
$(".js-slider").bxSlider({
infiniteLoop: false
});
BxSlider duplicates elements to allow infinite scrolling, etc. For example, say you only have two elements in your slider. Element one might be sliding out on the left, but also sliding in on the right. Therefore, duplicates are required.
If this is a problem, you can usually interact with the duplicates using their bx-clone classes. If you could clarify the actual problem, we could probably give more specific advice.
Update: To eliminate cloned elements from your set, try something like:
$('.bxslider li:not(.bx-clone)')....
I had such problem with bx-clone
I want to use it for an image gallery. So I had a thumbnail image slider and for slider I used bx-slider and on each click on small image , that image in bigger size must show in a div , But on bx-clone clicked nothing happened
I solved that problem with this :
var slider = $('.bxslider').bxSlider({
minSlides: 4,
maxSlides: 4,
slideWidth: 92,
moveSlides: 1,
pager: false,
slideMargin: 10,
onSliderLoad: function(){
$('li.bx-clone').click(function() {
/** your code for bx clone click event **/
});
}
});
Adding to #antongorodezkiy's answer, there is a way to have infiniteLoop: false and still get a non-stopping slide changing: using the onSlideAfter event of the last slide you can, after a few seconds, go back to the first slide and re-start the auto mode:
var pauseTime = 4000; //Time each slide is shown in ms. This is the default value.
var timeoutId;
var slider = $('.bxslider').bxSlider({
auto: true,
infiniteLoop: false,
pause: pauseTime,
onSlideAfter: function ($slideElement, oldIndex, newIndex) {
if (newIndex === slider.getSlideCount() - 1) { //Check if last slide
setTimeout(
function () {
slider.goToSlide(0);
slider.startAuto(); //You need to restart the "auto" mode
},
pauseTime //Use the same amount of time the slider is using
);
}
else { //In case the user changes the slide before the timeout fires
clearTimeout(timeoutId);
slider.startAuto(); //Doesn't affects the slider if it's already on "auto" mode
}
}
});
The difference between this solution and the infiniteLoop: true option is that instead of smoothly transitioning back to the first slide as if it was the next, the slider quickly "rewinds" until reaching the first slide.
for above query: Is it possible to keep having the infinite loop, but remove the clones?
try using below code: if more than 1 item infiniteloop: true else :false
infiniteLoop: ($j("...selector...").length < 2) ? false : true,
Just to answer here, so if some one is struggling and cannot fix the duplication issue. I was facing the same problem that all of my HTML from my page was duplicating inside the first slide under the image tag like bellow:
<img src="public/admin/scr3.png" ><div>..... all of my page HTML...</div></img>
I just found that I was writing the image tag not properly
Meaning my code was something like this for image tag
<img src="public/admin/scr3.png" >
I just replaced my image tag with valid HTML like bellow:
<img src="public/admin/scr3.png" />
and it fixed the content duplication issue.
Hope it will help someone.
Cheers!
I´m not sure if it´s the same issue I was facing, but here´s my case:
My code was using bx slider together with fancybox. And it was duplicating my slides. The solution was to put the secodary code (fancy box), which was generated in my image loop, inside the tag. That did it for me.
I'm making a site that makes use of the iosSlider plugin. I have a few sliders inside of a jquery accordion so some of them start out "display:none" when the page first loads. As a result the sliders inside the accordions are not getting the proper screen width. When you open one of the hidden accordions the slider inside is tiny.
I was curious if there was a better method to solving this issue then the one I am currently using. Right now I am simply destroying the slider and recalling it but this looks ugly and I'm sure there is probably a better approach to solving this.
Any input would be great, thanks
Current code:
$(".acheader").click(function(e) {
//e.preventDefault();
e.stopPropagation();
acords.slideUp();
$(".menuarrow").attr('src','/themes/images/arrow_down.png');
var image = $(this).find(".menuarrow");
if(image.attr('src') === "/themes/images/arrow_down.png"){
image.attr('src','/themes/images/arrow_up.png');
}
if ($(this).next().is(":hidden")) {
$(this).siblings(".accontent").slideToggle(100);
$('.iosSlider2').iosSlider('destroy');
$('.iosSlider2').iosSlider({
snapToChildren: true,
desktopClickDrag: true,
keyboardControls: true,
navNextSelector: $('.next'),
navPrevSelector: $('.prev'),
onSlideChange: slideChange2
});
}
else image.attr('src','/themes/images/arrow_down.png');
});
EDIT: this is for a mobile site so there are no static widths I can refer to. The sliders parents inherit their widths from their parents.. etc.
Taking a look at the iosSlider docs, under public methods, it looks like there is an update command which should resize it. Use $('.iosSlider2').iosSlider('update'); instead of destroying. Does that help?