Fancybox : The requested content cannot be loaded message on some items - fancybox

I have a website built in php codeigntier framework.
I have index page that's dynamically loading "li" elements and each "li" element has "a" tag which should display some item information via fancybox. Sometimes it is working, but sometimes it opens fancybox window, but instead of content it shows : "The requested content cannot be loaded message on some items".
Here is the code and after it i will explain what i did here:
index.php view (display page)
<li class="col-1-3">
<h3>
<?=$itm['name'];?>
</h3>
<figure class="full-width">
<a id="inline" href="#data-<?=$itm['code']?>" class="inset-border zoom-hover" data-zoom-hover-title="Detalji">
<img src="/slike/<?php echo $itm['img_name']?>" data-2x="/slike/<?php echo $itm['img_name']?>" width="124" height="150" alt="" />
</a>
</figure>
<p>
<b>Cena</b>: <?=$itm['price'];?> <br/>
<b>Sifra</b>: <?=$itm['code'];?><br/>
<b>PDV</b>: 19%
</p>
<b>Kolicina</b>: <input type="qty" class="qty-<?php echo $itm['id'];?>" name="qty" onkeypress="return isNumberKey(event)" size="3" maxlength="3"/>
<?php if($is_logged){?>
<p>
<a href="#_" class="buyButton big" name="<?php echo $itm['name'] ?>" id="<?php echo $itm['id'];?>" >
<span>Dodaj</span>
<i class="icon-plus color-blue"></i>
</a>
</p>
<?php }else{ ?>
<p>
<a id="loged" href="$_" class="infoButton big">
<span>Info</span>
<i class="icon-info"></i>
</a>
</p>
<?php } ?>
<div style="display:none">
<div id="data-<?=$itm['code']?>">
<figure id="images" class="alignleft">
<img src="/slike/<?php echo $itm['img_name']?>" data-2x="/slike/<?php echo $itm['img_name']?>" width="250" height="350" alt="" />
</figure>
<h3><?=$itm['name']?></h3>
<p><b>Cena Artikla: </b> <?=$itm['price']?> RSD<br/>
<b>Opis artikla: </b><?=$itm['descr'];?></p>
</div>
</div>
<!--<div style="display:none">
<div id="log">
<p>Morate biti ulogovani da bi ste kupili artikal</p>
</div>
</div>-->
</li>
So, dynamically adss data- ITEMID to every li item, and below
<div style="display:none">
<div id="data-<?=$itm['code']?>">
<figure id="images" class="alignleft">
<img src="/slike/<?php echo $itm['img_name']?>" data-2x="/slike/<?php echo $itm['img_name']?>" width="250" height="350" alt="" />
</figure>
<h3><?=$itm['name']?></h3>
<p><b>Cena Artikla: </b> <?=$itm['price']?> RSD<br/>
<b>Opis artikla: </b><?=$itm['descr'];?></p>
</div>
</div>
has same ITEMID dynamically added.
So, by clicking on that , hidden info should display in fancybox... and it is working, sometimes.. sometimes not...
Here is my js file:
$("a#inline").fancybox({
'hideOnContentClick': true
});
which is, of course, included in header of page, as fancybox.js file...
Any one has solution or suggestion ?
Thanks in advance.
p.s. you can visit poljoprivrednaapoteka.com and see the problem, just try clicking on few items, and the problem will pop..

Related

How can I get mongoDB data in different bootstrap cards

I am creating a News Blog Website. I have multiple cards in my home page showing news blog.
The structure of card are as follows:-
<div class="container">
<div class="row">
<!-- Blog entries-->
<div class="col-lg-8">
<!-- Featured blog post-->
<div class="card mb-4">
<!-- This is the latest trending news so I created this card to be big -->
</div>
</div>
<div class="row">
<!-- Now here I want 2 blog news in 1 row -->
<div class="col-lg-6">
<!--- Blog post-->
<div class="card mb-4">
<!-- 1st news -->
</div>
<div class="card mb-4">
<!-- 2nd News -->
</div>
</div>
<div class="col-lg-6">
<!--- Blog post-->
<div class="card mb-4">
<!-- 1st news -->
</div>
<div class="card mb-4">
<!-- 2nd News -->
</div>
</div>
</div>
Pictorial structure of my website is as shown here
Pictorial representation of my website
I want to add the latest last data entered in my mongoDB to go inside the big card (featured post) and rest all to go in the smaller cards in reverse order(the last data entered in database to be showed first).
My blog data in DB is as shown below
const post = new Post({
date: req.body.postDate,
title: req.body.postTitle,
content: req.body.postBody,
videoLink: req.body.postLink,
imgLink: req.body.postImgLink
});
post.save(function(err) {
if (!err) {
res.redirect("/");
}
});
and the data is loaded in home page as shown below
<% posts.forEach(function(post) { %>
<div class="/card mb-4">
<img class="card-img-top" src="<%= post.imgLink %>" alt="..." />
<div class="card-body">
<div class="small text-muted">
<%= post.date %>
</div>
<h2 class="card-title h4">
<%= post.title %>
</h2>
<p class="card-text">
<%- (post.content.substring(0, 250) + "..."); %>
</p>
<a class="btn btn-primary" href="/posts/<%= post._id %>">Read more →</a>
</div>
</div>
<% }); %>
Please help me, as I am new and trying to learn Full Stack Development. Sorry for my English and if my question sounds silly to you.

How to hide the name of a page from a list if it has no child sub pages in sightly?

I want to display only those pages in the header which have child pages inside them. Using the following code
<nav class="wsmenu clearfix" data-sly-use.nav="in.gov.odishatourism.core.models.HeaderNavigation">
<ul class="wsmenu-list" >
<li aria-haspopup="true" data-sly-repeat="${nav.root.listChildren}" ><span class="wsmenu-click" ><i class="wsmenu-arrow fa fa-angle-down"></i></span>
<a class="" href="javascript:void(0);" data-sly-test="!${item.hasChild}">${item.title}</a>
<div class="wsmegamenu clearfix ">
<div class="container paddingmenu">
<div class="row">
<div class="menuimgdiv" data-sly-repeat.subcategory="${item.listChildren}">
<h3 class="title" data-sly-test.subcat="${subcategory.title}" >${subcat}</h3>
<ul>
<li data-sly-repeat.page="${subcategory.listChildren}"><a class="" href="${page.path # extension='html'}">${page.title}</a></li>
</ul>
</div>
</div>
</div>
</div>
</li>
<li aria-haspopup="true"> Dept of Tourism</li>
</ul>
<a class="wsdownmenu-animated-arrow"><span></span></a>
<div class="wsdownmenu-text">Navigation</div>
</nav>
gives the following output
But this code -
<nav class="wsmenu clearfix" data-sly-use.nav="in.gov.odishatourism.core.models.HeaderNavigation">
<ul class="wsmenu-list" >
<li aria-haspopup="true" data-sly-repeat="${nav.root.listChildren}" ><span class="wsmenu-click" ><i class="wsmenu-arrow fa fa-angle-down"></i></span>
<a class="" href="javascript:void(0);" data-sly-test="${item.hasChild}">${item.title}</a>
<div class="wsmegamenu clearfix ">
<div class="container paddingmenu">
<div class="row">
<div class="menuimgdiv" data-sly-repeat.subcategory="${item.listChildren}">
<h3 class="title" data-sly-test.subcat="${subcategory.title}" >${subcat}</h3>
<ul>
<li data-sly-repeat.page="${subcategory.listChildren}"><a class="" href="${page.path # extension='html'}">${page.title}</a></li>
</ul>
</div>
</div>
</div>
</div>
</li>
<li aria-haspopup="true"> Dept of Tourism</li>
</ul>
<a class="wsdownmenu-animated-arrow"><span></span></a>
<div class="wsdownmenu-text">Navigation</div>
</nav>
gives the output as shown below
The code
<a class="" href="javascript:void(0);" data-sly-test="${item.hasChild}">${item.title}</a>
is not working properly.
My site structure is as shown below
And the actual desired output is
You cannot use ${item.hasChild} in your test condition as the hasChild() method of the Page API requires you to pass a parameter. AFAIK, HTL doesn't support invocation of parameterized methods.
Since there is no direct API available to check if a page has child pages or not, you may need to do the following to validate if the page has child pages
<a class="" href="javascript:void(0);" data-sly-test="${item.listChildren && item.listChildren.hasNext}">${item.title}</a>
However, I would prefer building the entire navigation tree using Sling models or WCM Use API and not invoking so many methods in the HTL. That would make the code easier to maintain, change and test. YMMV

Accordion open next on button click

Hi been searching for few days now but couldnt find anything. I have an accordion that has three accordion group, I have added a button to open the next accordion but cant seem to get it working. Can some one please help. here is what I have so far
<accordion [closeOthers]="true" style="margin-top:5px;">
<accordion-group *ngFor="let registration of registrationArray; let i = index" #groupval style="margin-top:5px;" [isOpen]="registration.isAccordionOpen">
<div accordion-heading style="width:100%;">
Registrant No. {{i + 1}}
<i class="pull-right float-xs-right glyphicon"
[ngClass]="{'glyphicon-chevron-down': groupval?.isOpen, 'glyphicon-chevron-up': !groupval?.isOpen}"></i>
</div>
<form [formGroup]="myGroup" (ngSubmit)="gotoAddons(myDetails)">
<div formArrayName="myDetails">
<div class="panel-body" [formGroupName]="i">
<div style="padding-top:20px;clear:both;">
<div style="width:100%;background-color:#578ebe;border: 1px solid #7ca7cc;">
Your Address
</div>
<div style="padding-top:30px;clear:both;">
<div style="width:100%">
<div style="float:left;width:30%;text-align:right;">
<span class="required">*</span><label>Address Line 1</label>
</div>
<div style="float:left;width:70%;padding-left:10px;">
<input autofocus class="form-control" type="text" id="address" name="address" formControlName="address" required>
<div *ngIf="myGroup.controls.myDetails.controls[i].controls.address.errors && (myGroup.controls.myDetails.controls[i].controls.address.dirty || myGroup.controls.myDetails.controls[i].controls.address.touched || submitted)" class="alert alert-danger">
<div [hidden]="!myGroup.controls.myDetails.controls[i].controls.address.errors.required">
Address Line 1 is required!
</div>
</div>
</div>
</div>
</div>
</div>
<div style="width:100%;" *ngIf="i < registrationArray.length - 1">
<div style="float:right;">
<button (click)="groupval.isOpen = !groupval.isOpen" class="btn green">Open next tab</button>
</div>
</div>
<div style="width:100%;" *ngIf="i == registrationArray.length - 1" >
<div style="float:right;">
<button type="submit" class="btn green">Continue</button>
</div>
</div>
</div>
</div>
</form>
</accordion-group>
</accordion>
Removed some code for clarification. Can some one please let me know how I can open the next accordion group on the button click. Thanks in advance
Here is a working example
plunkr
stackblitz link
stackblitz
In your case I see that you're actually just closing the opened panel and that's all. Along with this you need to open a next panel which can be done by setting its isOpen property to true.
A small plunkr with test implementation - https://stackblitz.com/edit/ngx-bootstrap-ifmpph?file=app/app.component.html

How to dynamically disable form submit button when using Bootstrap validation

I have a form that is validated using Bootstrap Validator http://1000hz.github.io/bootstrap-validator/.
You don't see the form at first (display: none). When you get to the step where you fill out the form, the Submit button is enabled, although the form is not valid.
However, if I display the form right away, the Submit button is disabled until the form is valid, as I want it to be. Does anyone have idea why is this happening and how to get it to work?
<div id="step0">
Some code here that is visible in the first step
<div class="row">
<button type="button" class="btn btn-primary" onclick="step1();">Go to step 1</button>
</div>
</div>
<div id="step1" style="display: none;">
<form id="forma-klijenta" data-toggle="validator" method="post" action="test.php">
<div class="row">
<div class="col-md-8 col-sm-12 form-right">
<h3> Lični podaci </h3>
<div class="row">
<div class="col-xs-12 form-group col-sm-6">
<input autocomplete="off" class="form-control" id="ime" data-minlength="2" name="ime" placeholder="Ime" required type="text" value=""
pattern="^[A-ZŠĐČĆŽa-zšđčćž]([-' ]?[A-ZŠĐČĆŽa-zšđčćž])+$"data-error="Ime je obavezno. Dozvoljeni specijalni karakteri su - i '." />
<div class="help-block with-errors"></div>
</div>
</div>
</div>
</div>
<div class="row form-group">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</form>
<!-- Kraj forme za unos podataka -->
</div>
This is how I worked around this:
Removed style="display: none;"
Added jQuery
$(document).ready(function(){
$("#step1").hide();
});

Facebook Style Comment Box

I have tweets and commenting system like this
This is the code block for one set of tweet and its comments and commenting box:
<li class="storyBlock">
<div>
<div class="grid userImageBlockL">
<div class="imgMedium"> <img width="44" height="44" alt="image" src="/bakasura1/files/images/medium/1288170363aca595cabb50.jpg"> </div>
</div>
<div class="grid userContentBlockL">
<div class="userContentHeader">
<h5> Harsha Vantagudi <span class="storyMessage">Testing the Seconds</span></h5>
<span class="user-status-time">6 hours ago</span> <span>Comment Delete</span> </div>
<ul class="commentList">
<li class="commentBlock">
<div>
<div class="grid userImageBlockS">
<div class="imgSmall"> <img width="35" height="35" alt="image" src="/bakasura1/files/images/small/1288170363aca595cabb50.jpg"> </div>
</div>
<div class="grid userContentBlockS alpha omega">
<h5> Harsha Vantagudi <span class="storyMessage">Write your comment...</span></h5>
<span class="user-status-time">27 minutes ago</span> <span>Comment Delete</span></div>
<div class="clear"></div>
</div>
</li>
<li class="commentBlock">
<div>
<div class="grid userImageBlockS">
<div class="imgSmall"> <img width="35" height="35" alt="image" src="/bakasura1/files/images/small/1288170363aca595cabb50.jpg"> </div>
</div>
<div class="grid userContentBlockS alpha omega">
<form accept-charset="utf-8" action="/bakasura1/account/saveComment" method="post">
<div style="display: none;">
<input type="hidden" value="POST" name="_method">
</div>
<input type="hidden" id="StatusMessageReplyPid" value="67" name="data[StatusMessageReply][pid]">
<input type="hidden" id="StatusMessageReplyItemId" value="1" name="data[StatusMessageReply][item_id]">
<input type="hidden" id="StatusMessageReplyCommentersItemId" value="1" name="data[StatusMessageReply][commenters_item_id]">
<textarea id="StatusMessageReplyMessage" name="data[StatusMessageReply][message]">Write your comment...</textarea>
<input type="submit" name="" value="Comment">
</form>
</div>
<div class="clear"></div>
</div>
</li>
</ul>
</div>
<div class="clear"></div>
</div>
</li>
I am a little confused as to how to create an Ajax from submit when the comment is saved the new comment should stack top to bottom. Since there is no unique tweet identifier. I am not sure how to address this problem.
Can some one recommend an easy solution for the same?
http://demos.99points.info/facebook_wallpost_system/
nice demo and tutorial there
Did you try this plugin ,
http://timeago.yarp.com/
this should help