Programmatically open fancybox passing an array











up vote
0
down vote

favorite












I have a question regarding jquery fancybox .



My code in load():



$(".fanciogallery").on("click", function(e){
e.preventDefault();
var gid = $(this).data("gid");

var fancyarray = ;
//already have an array with the infos
gallery_array[gid].forEach(function(element){
var impa = uploadfold + gid + '/immages_' + element.id_img + '.png';
//fill an array to pass to fancybox
fancyarray.push(
{href : impa, title : 'Title'}
);
});

$.fancybox.open(
fancyarray,
{
//options
loop : false
},
);
});


I am doing some testing so it's not complete or refined.
I get "The requested content cannot be loaded" but it seems to get the number of elements right.



I get this error even if I hardcode a valid imagepath into



href:


probably I am filling the array wrong, the documentation it's not clear for me.
Do you know what I am doing wrong?



Thank you










share|improve this question
























  • try to debug it and checks if your gallery_array[gid] is isset and not empty.
    – Oleg Nurutdinov
    2 days ago










  • yes yes it's non-empty. Thank you
    – Luca Calabrese
    2 days ago












  • It looks like you try to push json in array, maybe this can helps you? stackoverflow.com/questions/12383070/json-array-pushing
    – Oleg Nurutdinov
    2 days ago












  • possible duplicate? stackoverflow.com/questions/8828173/…
    – Pete
    2 days ago















up vote
0
down vote

favorite












I have a question regarding jquery fancybox .



My code in load():



$(".fanciogallery").on("click", function(e){
e.preventDefault();
var gid = $(this).data("gid");

var fancyarray = ;
//already have an array with the infos
gallery_array[gid].forEach(function(element){
var impa = uploadfold + gid + '/immages_' + element.id_img + '.png';
//fill an array to pass to fancybox
fancyarray.push(
{href : impa, title : 'Title'}
);
});

$.fancybox.open(
fancyarray,
{
//options
loop : false
},
);
});


I am doing some testing so it's not complete or refined.
I get "The requested content cannot be loaded" but it seems to get the number of elements right.



I get this error even if I hardcode a valid imagepath into



href:


probably I am filling the array wrong, the documentation it's not clear for me.
Do you know what I am doing wrong?



Thank you










share|improve this question
























  • try to debug it and checks if your gallery_array[gid] is isset and not empty.
    – Oleg Nurutdinov
    2 days ago










  • yes yes it's non-empty. Thank you
    – Luca Calabrese
    2 days ago












  • It looks like you try to push json in array, maybe this can helps you? stackoverflow.com/questions/12383070/json-array-pushing
    – Oleg Nurutdinov
    2 days ago












  • possible duplicate? stackoverflow.com/questions/8828173/…
    – Pete
    2 days ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a question regarding jquery fancybox .



My code in load():



$(".fanciogallery").on("click", function(e){
e.preventDefault();
var gid = $(this).data("gid");

var fancyarray = ;
//already have an array with the infos
gallery_array[gid].forEach(function(element){
var impa = uploadfold + gid + '/immages_' + element.id_img + '.png';
//fill an array to pass to fancybox
fancyarray.push(
{href : impa, title : 'Title'}
);
});

$.fancybox.open(
fancyarray,
{
//options
loop : false
},
);
});


I am doing some testing so it's not complete or refined.
I get "The requested content cannot be loaded" but it seems to get the number of elements right.



I get this error even if I hardcode a valid imagepath into



href:


probably I am filling the array wrong, the documentation it's not clear for me.
Do you know what I am doing wrong?



Thank you










share|improve this question















I have a question regarding jquery fancybox .



My code in load():



$(".fanciogallery").on("click", function(e){
e.preventDefault();
var gid = $(this).data("gid");

var fancyarray = ;
//already have an array with the infos
gallery_array[gid].forEach(function(element){
var impa = uploadfold + gid + '/immages_' + element.id_img + '.png';
//fill an array to pass to fancybox
fancyarray.push(
{href : impa, title : 'Title'}
);
});

$.fancybox.open(
fancyarray,
{
//options
loop : false
},
);
});


I am doing some testing so it's not complete or refined.
I get "The requested content cannot be loaded" but it seems to get the number of elements right.



I get this error even if I hardcode a valid imagepath into



href:


probably I am filling the array wrong, the documentation it's not clear for me.
Do you know what I am doing wrong?



Thank you







javascript jquery image fancybox






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago









barbsan

2,131521




2,131521










asked 2 days ago









Luca Calabrese

374




374












  • try to debug it and checks if your gallery_array[gid] is isset and not empty.
    – Oleg Nurutdinov
    2 days ago










  • yes yes it's non-empty. Thank you
    – Luca Calabrese
    2 days ago












  • It looks like you try to push json in array, maybe this can helps you? stackoverflow.com/questions/12383070/json-array-pushing
    – Oleg Nurutdinov
    2 days ago












  • possible duplicate? stackoverflow.com/questions/8828173/…
    – Pete
    2 days ago


















  • try to debug it and checks if your gallery_array[gid] is isset and not empty.
    – Oleg Nurutdinov
    2 days ago










  • yes yes it's non-empty. Thank you
    – Luca Calabrese
    2 days ago












  • It looks like you try to push json in array, maybe this can helps you? stackoverflow.com/questions/12383070/json-array-pushing
    – Oleg Nurutdinov
    2 days ago












  • possible duplicate? stackoverflow.com/questions/8828173/…
    – Pete
    2 days ago
















try to debug it and checks if your gallery_array[gid] is isset and not empty.
– Oleg Nurutdinov
2 days ago




try to debug it and checks if your gallery_array[gid] is isset and not empty.
– Oleg Nurutdinov
2 days ago












yes yes it's non-empty. Thank you
– Luca Calabrese
2 days ago






yes yes it's non-empty. Thank you
– Luca Calabrese
2 days ago














It looks like you try to push json in array, maybe this can helps you? stackoverflow.com/questions/12383070/json-array-pushing
– Oleg Nurutdinov
2 days ago






It looks like you try to push json in array, maybe this can helps you? stackoverflow.com/questions/12383070/json-array-pushing
– Oleg Nurutdinov
2 days ago














possible duplicate? stackoverflow.com/questions/8828173/…
– Pete
2 days ago




possible duplicate? stackoverflow.com/questions/8828173/…
– Pete
2 days ago












1 Answer
1






active

oldest

votes

















up vote
0
down vote



accepted










Check samples from documentation - http://fancyapps.com/fancybox/3/docs/#api -



$.fancybox.open([
{
src : '1_b.jpg',
opts : {
caption : 'First caption',
thumb : '1_s.jpg'
}
},
{
src : '2_b.jpg',
opts : {
caption : 'Second caption',
thumb : '2_s.jpg'
}
}
], {
loop : false
});


Basically, replace href with src






share|improve this answer





















  • I feel very stupid now.
    – Luca Calabrese
    2 days ago










  • No worries, you were using syntax from v2, but v3 has completely different API.
    – Janis
    yesterday











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373090%2fprogrammatically-open-fancybox-passing-an-array%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote



accepted










Check samples from documentation - http://fancyapps.com/fancybox/3/docs/#api -



$.fancybox.open([
{
src : '1_b.jpg',
opts : {
caption : 'First caption',
thumb : '1_s.jpg'
}
},
{
src : '2_b.jpg',
opts : {
caption : 'Second caption',
thumb : '2_s.jpg'
}
}
], {
loop : false
});


Basically, replace href with src






share|improve this answer





















  • I feel very stupid now.
    – Luca Calabrese
    2 days ago










  • No worries, you were using syntax from v2, but v3 has completely different API.
    – Janis
    yesterday















up vote
0
down vote



accepted










Check samples from documentation - http://fancyapps.com/fancybox/3/docs/#api -



$.fancybox.open([
{
src : '1_b.jpg',
opts : {
caption : 'First caption',
thumb : '1_s.jpg'
}
},
{
src : '2_b.jpg',
opts : {
caption : 'Second caption',
thumb : '2_s.jpg'
}
}
], {
loop : false
});


Basically, replace href with src






share|improve this answer





















  • I feel very stupid now.
    – Luca Calabrese
    2 days ago










  • No worries, you were using syntax from v2, but v3 has completely different API.
    – Janis
    yesterday













up vote
0
down vote



accepted







up vote
0
down vote



accepted






Check samples from documentation - http://fancyapps.com/fancybox/3/docs/#api -



$.fancybox.open([
{
src : '1_b.jpg',
opts : {
caption : 'First caption',
thumb : '1_s.jpg'
}
},
{
src : '2_b.jpg',
opts : {
caption : 'Second caption',
thumb : '2_s.jpg'
}
}
], {
loop : false
});


Basically, replace href with src






share|improve this answer












Check samples from documentation - http://fancyapps.com/fancybox/3/docs/#api -



$.fancybox.open([
{
src : '1_b.jpg',
opts : {
caption : 'First caption',
thumb : '1_s.jpg'
}
},
{
src : '2_b.jpg',
opts : {
caption : 'Second caption',
thumb : '2_s.jpg'
}
}
], {
loop : false
});


Basically, replace href with src







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









Janis

6,09311322




6,09311322












  • I feel very stupid now.
    – Luca Calabrese
    2 days ago










  • No worries, you were using syntax from v2, but v3 has completely different API.
    – Janis
    yesterday


















  • I feel very stupid now.
    – Luca Calabrese
    2 days ago










  • No worries, you were using syntax from v2, but v3 has completely different API.
    – Janis
    yesterday
















I feel very stupid now.
– Luca Calabrese
2 days ago




I feel very stupid now.
– Luca Calabrese
2 days ago












No worries, you were using syntax from v2, but v3 has completely different API.
– Janis
yesterday




No worries, you were using syntax from v2, but v3 has completely different API.
– Janis
yesterday


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53373090%2fprogrammatically-open-fancybox-passing-an-array%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

android studio warns about leanback feature tag usage required on manifest while using Unity exported app?

SQL update select statement

'app-layout' is not a known element: how to share Component with different Modules