Closed alexweb-zz closed 8 years ago
@alexweb I am not sure if its the plugin but i tried and it works
Hm. Very strange. When I insert the code above to the blank page and click on thumbnails, two overlays appear and big image is hidden.
Maybe something with your CSS?
I don't think so. When there is one gallery on the page it works correctly. So you copied all the code above and it works? Looks like when there are two galleries on the page, the extension creates two sets of gallery controls. So when you click on thumbnail, two overlays and two sets of gallery controls (next/forward) apear. When there are 3 galleries - 3 overlays appear etc. Btw they have the same IDs, maybe that is the problem?
Hi, it works, but the problem is that it renders twice the template and thats bad. In order to make it work with multiple galleries I would require to modify the plugin itself, OR, I should make sure the template is always one by rendering a custom script.
See how your code renders two rows of pictures:
Will update to make sure it doesn't render twice the template.
In my case, I create a multiply galleries on one page with Ajax-request
This is javascript in my main view:
$.post('{$coolGalleryUrl}', {'gallery': $(gObj).attr("id")}, function(rData){
$(gObj).html(rData);
});
Controller find a models and
$this->renderAjax('_gallery', ['model' => $gallery]);
And _gallery
view
echo Gallery::widget([
'items' => $items,
'options' => [
'id' => 'gallery-widget-' . $model->id,
],
'templateOptions' => [
'id' => 'blueimp-gallery-' . $model->id
],
'clientOptions' => [
'container' => '#blueimp-gallery-' . $model->id
]
]);
So, I have two (for example) js-calls in main view and two galleries on one page, and id
of widgets and id
of gallery containers is mine, but a javascript-call
dosamigos.gallery.registerLightBoxHandlers('#gallery-widget-7 a', {"container":"#blueimp-gallery-7"});
is not work, because a options
parameter in dosamigos-blueimp-gallery.js
is undefined
.
Also, this code
if (typeof dosamigos == "undefined" || !dosamigos) {
var dosamigos = {};
}
dosamigos.gallery = (function($){
var pub = {
registerLightBoxHandlers: function(selector, options) {
$(document).off('click.gallery', selector).on('click.gallery', selector, function() {
var links = $(this).parent().find('a.gallery-item');
var options = options || {};
options.index = $(this)[0];
blueimp.Gallery(links, options);
return false;
});
}
};
return pub;
})(jQuery);
not work in my case, but this
if (typeof dosamigos == "undefined" || !dosamigos) {
var dosamigos = {};
}
dosamigos.gallery = (function($){
var pub = {
registerLightBoxHandlers: function(selector, options) {
var options = options || {}; // options is here!
$(document).off('click.gallery', selector).on('click.gallery', selector, function() {
var links = $(this).parent().find('a.gallery-item');
options.index = $(this)[0];
blueimp.Gallery(links, options);
return false;
});
}
};
return pub;
})(jQuery);
work for me.
I don`t know, is this correct, but may be You tested? And change, if test is passed?
P.S. My English is terrible, sorry :)
thank you!
+1 Yes, this fixes the problem, thank you @andrew72ru
registerLightBoxHandlers: function(selector, options) {
var options = options || {}; // options is here!
...
This bug is still present in actual version. Doesnt work modifing from original code with opts to options. Why? How to fix that while author didnt fix his own bugs?
if (typeof dosamigos == "undefined" || !dosamigos) { var dosamigos = {}; } dosamigos.gallery = (function($){ var pub = { registerLightBoxHandlers: function(selector, opts) { var options = opts || {}; $(document).off('click.gallery', selector).on('click.gallery', selector, function() { var links = $(this).parent().find('a.gallery-item'); options.index = $(this)[0]; blueimp.Gallery(links, options); return false; }); } }; return pub; })(jQuery);
Awful fix that works: add a static member on Gallery class, and test it when the template is rendered
class Gallery extends Widget
{
static $singleRender = false;
//...
public function renderTemplate()
{
if (!self::$singleRender) {
self::$singleRender = true;
} else {
return "<-- NO RENDER -->";
}
//...
}
//...
}
Awful fix that works: add a static member on Gallery class, and test it when the template is rendered
class Gallery extends Widget { static $singleRender = false; //... public function renderTemplate() { if (!self::$singleRender) { self::$singleRender = true; } else { return "<-- NO RENDER -->"; } //... } //... }
This is work for me.
It can show multiple instant lightbox.
When I added two galleries to the page, they looks like not work. Try: