I am new in jquery mobile and jquery also. I am working on a project with phonegap and jquery mobile. I am using PhotoSwipe for image gallery. It is working nice and show the images. But I want to make a custom toolbar for photoswipe for my gallery. I saw their given custom-toolbar sample and almost made it. But though I am new in this sector so I failed to integrate it with jquery mobile. And my custom button does not work at all. Here is my code sample.
for (var i = 0; i < photo_len; i++) {
$('.GalleryAccessories').append('<li><a href="' + image_item[i].original + '" rel="external"><img src="' + image_item[i].original + '" alt=""/></a></li>');
}
$('.GalleryAccessories').trigger("create");
var myPhotoSwipe = $(".GalleryAccessories a").photoSwipe({
getToolbar: function(){
return '<div class="ps-toolbar-close" style="padding-top: 12px;">Back</div><div class="ps-toolbar-play" style="padding-top: 12px;">Play</div><div class="ps-toolbar-previous" style="padding-top: 12px;">Previous</div><div class="ps-toolbar-next" style="padding-top: 12px;">Next</div><div class="ps-toolbar-close" style="padding-top: 12px;">View All</div>';
},
jQueryMobile: true,
loop: false,
enableMouseWheel: false,
enableKeyboard: false
});
myPhotoSwipe.show(0);
View All button doesn't work at all. I have tried their given code but no luck. I even tried just what i do now but still it doesn't work. Sorry for my poor english. Please help me... Thanks in advance.
I am new in jquery mobile and jquery also. I am working on a project with phonegap and jquery mobile. I am using PhotoSwipe for image gallery. It is working nice and show the images. But I want to make a custom toolbar for photoswipe for my gallery. I saw their given custom-toolbar sample and almost made it. But though I am new in this sector so I failed to integrate it with jquery mobile. And my custom button does not work at all. Here is my code sample.
for (var i = 0; i < photo_len; i++) {
$('.GalleryAccessories').append('<li><a href="' + image_item[i].original + '" rel="external"><img src="' + image_item[i].original + '" alt=""/></a></li>');
}
$('.GalleryAccessories').trigger("create");
var myPhotoSwipe = $(".GalleryAccessories a").photoSwipe({
getToolbar: function(){
return '<div class="ps-toolbar-close" style="padding-top: 12px;">Back</div><div class="ps-toolbar-play" style="padding-top: 12px;">Play</div><div class="ps-toolbar-previous" style="padding-top: 12px;">Previous</div><div class="ps-toolbar-next" style="padding-top: 12px;">Next</div><div class="ps-toolbar-close" style="padding-top: 12px;">View All</div>';
},
jQueryMobile: true,
loop: false,
enableMouseWheel: false,
enableKeyboard: false
});
myPhotoSwipe.show(0);
View All button doesn't work at all. I have tried their given code but no luck. I even tried just what i do now but still it doesn't work. Sorry for my poor english. Please help me... Thanks in advance.
Share Improve this question edited May 20, 2013 at 14:34 Gajotres 57.3k16 gold badges105 silver badges131 bronze badges asked May 3, 2013 at 13:00 SakibSakib 4725 silver badges17 bronze badges 5- Plz help me... I am trying but no luck for me. – Sakib Commented May 6, 2013 at 3:48
- 1 what error are you getting? can you reproduce the problem using jsfiddle? – Omar Commented May 6, 2013 at 8:55
- @Omar, I am getting any error. Back, play, previous, next buttons are working fine but view all button don't work. I have use "ps-toolbar-close" for both back and view all. is it a problem? if yes i have no idea about how to solve it. – Sakib Commented May 6, 2013 at 9:29
- sorry, means do not get any error. – Sakib Commented May 6, 2013 at 9:49
- I solved my extrabutton problem by adding a button on my header and show the gallery in a custom target. But cann't solve the real problem that i posted here to solve. – Sakib Commented May 10, 2013 at 11:27
1 Answer
Reset to default 7 +50Explanation
This is a PhotoSwipe bug, maybe not a bug but still a problem.
First let me ask you why do you want to have two buttons with same properties? Button Back and your button View All would do the same thing.
Photoswipe will enhance only first occurrence of a class ps-toolbar-close all others will be disregarded. To be hones I don't see the point of this solution. If user wants more buttons just let them have it.
This problem can be solved programmatically.
Solution
Working example: http://jsfiddle/Gajotres/nBZfT/
HTML :
<div class="ps-toolbar-close second-close" style="padding-top: 12px;">View All</div>
Javascript :
myPhotoSwipe.addEventHandler(window.Code.PhotoSwipe.EventTypes.onShow, function(e) {
$(document).off('click', '.second-close').on('click', '.second-close', function(){
e.target.hide();
});
});