fullpage.js dynamically added sections: how to scroll inside the sections - fullpage.js

I am adding the sections in HTML using JS from this object:
var slidesArray = [
{
'id': 1,
'title': '1 title',
},
{
'id': 2,
'title': '2 title',
},
{
'id': 3,
'title': '3 title',
},
{
'id': 4,
'title': '4 title',
}
];
like this:
var $container = $('#fullpage'),
shuffledItems = "",
shuffledItemsTemplate =
"<div class='section fp-scrollable'>" +
"<div class='section_title'>{TITLE}</div>" +
"</div>";
for(var i = 0; i < 3; i++) {
shuffledItems = shuffledItemsTemplate.replace(/{TITLE}/g, slidesArray[i]["title"]);
$container.append(shuffledItems);
}
which results in the following HTML:
<div id="fullpage" class="sections">
<div class="section fp-scrollable">
<div class="section_title">1 title</div>
</div>
<div class="section fp-scrollable">
<div class="section_title">2 title</div>
</div>
<!-- etc -->
</div>
Simple enough.
Here's the fullpage configuration:
new fullpage('#fullpage', {
css3: true,
scrollingSpeed: 1000,
navigation: true,
slidesNavigation: true,
controlArrows: false,
scrollOverflow: true, // even though this is set to true, it's not working
scrollOverflowOptions: {
scrollbars: false,
},
});
My problem is that I cannot scroll inside any div that's scrollable and is inside <div class="section"></div>, even though scrollOverflow: true is set, and I added the files in the correct order in the HTML. Any idea what might cause this issue and how to solve it?
<script src="Scripts/Legacy/vendor/jquery.min.js"></script>
<script src="Scripts/Legacy/third-party/scrolloverflow.min.js"></script>
<script src="Scripts/Legacy/third-party/fullpage.js"></script>

You might need to use the method fullpage_api.reBuid() right after appending a section. Try it out.
That, or initialise fullPage.js after appending the contents.
In any case, fullPage.js won't be able to detect new sections appended dynamically, you would have to put some more work from your part to make it work. Namely, destroying fullPage.js and initialising it again with every section/slide you add/remove dynamically.

Related

metronic datatable 6*4 grid of user-images

I would like to know if it is possible to use datatables (Metronic Laravel Theme) to display a 6*4 grid of user-images instead of displaying the images row-by-row (the standard datatable behavior). Anyone able to help?
ive just started on this so i don't want to waste a lot of time if it's not possible at all, this is what i have so far:
let members_datatable,
members_element = $('...');
members_datatable = members_element.MyCustomDataTable({
columns: [
{
field: 'id',
title: members_element.data('column-id'),
width: 50,
template: function (row) {
return row.id;
}
},
{
field: 'first_name',
title: members_element.data('column-name'),
width: 150,
template: function (row) {
let user_id = ...;
let user_company = ...;
let company_branche = ...;
return `<div class="mt-card-item">
<div class="mt-card-avatar mt-overlay-4">
<img src="storage/public/userImages/${user_id}.jpg">
<div class="mt-overlay">
<h2>${user_company}</h2>
<div class="mt-info font-white">
<div class="mt-card-content">
${company_branche}
</div>
</div>
</div>
</div>
</div>`;
}
},
],
});

Instagram feed carousel

I want to create a carousel that contain my instagram photo on my website. It's already working with simple grid style. This is the section where I put the feed:
<div id="instagram-feed-demo" class="instagram_feed"></div>
and this is the script:
<script type="text/javascript">
(function($) {
$(window).on('load', function() {
$.instagramFeed({
'username': 'iipex_id',
'container': "#instagram-feed-demo",
'display_profile': false,
'display_biography': false,
'display_gallery': true,
'get_raw_json': false,
'callback': null,
'styling': true,
'items': 9,
'items_per_row': 3,
'margin': 1
});
});
})(jQuery);
</script>
since I want to display it as carousel, I try to put the ID and Class into carousel :
<div id="instagram-feed-demo" class="carousel instagram_feed" data-items="3" data-dots="false" data-loop="true" data-autoplay="true" data-lightbox="gallery"></div>
but it's not working. maybe I have to create another script? or I made a mistake on my carousel ?

View single item inside kendo ui jquery scrollview

I have a scrollview which get json data from an api and render items inside scrollview. From the data i only need to render one item at a time.
Inorder to do that i try adding pageSize:1 to the data source but it does not render anything inside the scrollview. When pageSize change to 2, items render fine with 2 items inside scrollview.
How can i render only a one item inside scrollview?
<div id="example" style="margin:auto; width:60%">
<div id="scrollView" style="height: 600px; width:100%;"></div>
</div>
<script id="scrollview-template" type="text/x-kendo-template">
# for (var i = 0; i < data.length; i++) { #
<div data-role="page" style="width:100%;">
<img class="carousal-image" src="#=
getPreviewImageUrl(data[i].Type,data[i].PreviewImageUrl) #"/>
</div>
# } #
</script>
<script>
var dataSource = new kendo.data.DataSource({
transport: {
read: {
url: "sample api",
dataType: "json"
}
},
pageSize:1,
schema: {
data: "items"
},
});
$("#scrollView").kendoScrollView({
dataSource: dataSource,
template: $("#scrollview-template").html(),
contentHeight: "100%"
});
</script>
Sample josn data
{
"items": [
{
"PreviewImageUrl": "/images/ui/Default_News.png",
"Type": "NewsType"
},
{
"PreviewImageUrl": "/images/ui/Default_Blog.png",
"Type": "BlogType"
}
],
"total": 2
}
When the pageSize is greater than one, the data passed to the template is a javascript array, but when it equals one, data refers to the JSON object itself. Hence your template needs to be more like this:
<script id="scrollview-template" type="text/x-kendo-template">
# if (data != null) { #
<div data-role="page" style="width:100%;">
<img class="carousal-image"
src="#= getPreviewImageUrl(data.Type,data.PreviewImageUrl) #"/>
</div>
# } #
</script>
Working demo here. Hope this helps.

Simple Kendo DropDownList binding in window

I have a form with a DropDownList inside a Kendo window and I want to bind existing data to it. Examples for this abound and I've done it in other situations before, but this one (which seems like it should be really easy) is escaping me because I can't seem for the life of me to get the DropDownList to show the correct value. I figure I must be missing something really simple, but I haven't done Kendo in over a year, and looking at my previous work isn't helping me either.
Extremely simplified code:
<button onclick="OnButtonClick();">Click Me</button>
<div id="form-window"></div>
<script type="text/x-kendo-template" id="form-template">
<div class="form-group">
<label for="Url">URL</label>
<input name="Url" type="text" value="#= Url #" required="required" />
</div>
<div class="form-group">
<label for="HttpVerb">HTTP verb</label>
<input name="HttpVerb" data-bind="value:HttpVerb" data-source="httpVerbsDataSource" data-value-field="verb" data-text-field="verb" data-role="dropdownlist" />
</div>
</script>
<script type="text/javascript">
var formWindow = $("#form-window")
.kendoWindow({
title: "Form",
modal: true,
visible: false,
resizable: false,
scrollable: false,
width: 500,
actions: ["Close"],
open: function () {
kendo.init($("#form-window"));
}
}).data("kendoWindow");
var formTemplate = kendo.template($("#form-template").html());
var httpVerbsDataSource = new kendo.data.DataSource({
data: [
{ verb: "GET" },
{ verb: "POST" },
{ verb: "PUT" }
]
});
function OnButtonClick(e) {
var dataItem = {
Url: "abcdef",
HttpVerb: "POST"
};
var windowContent = formTemplate(dataItem);
formWindow.content(windowContent);
formWindow.center().open();
}
</script>
When I click the button, the window opens and the form text field is populated correctly, and the DropDownList has properly been bound to the data source, but the value in my data item is not selected.
JS Bin: https://jsbin.com/wariyorilo/edit?html,js,output
What am I missing? Thanks in advance.

data-bind not working in List View template within Grid detail template

I need help using a Kendo UI list view which lives within a grid row detail template.
here is something I have done so far.
<div id="grid">
</div>
<script type="text/x-kendo-template" id="gridDetailTemplate">
<div class='grid-edit'>
<div class='edit-list'></div>
</div>
</script>
<script type="text/x-kendo-template" id="editItemtemplate">
<div class='edit-Item'>
#if(Type=='string'){#
<ul><li><b>#:Name#</b></li><li><input class='inputString' value='#:DataVal()#'/></li></ul>
#}else if(Type=='number'){#
<ul><li><b>#:Name#</b></li><li><input class='inputNumber' data-role='numerictextbox' data-type='number' value='#:DataVal()#'/></li></ul>
#}else if(Type=='date'){#
<ul><li><b>#:Name#</b></li><li><input class='inputDate' data-role='datepicker' value='#:kendo.toString(DataVal(),'MM/dd/yyyy')#'/></li></ul>
#}else if(Type=='boolean'){Name #<input type='checkbox'/>
#}#
</div>
</script>
<script type="text/javascript">
$(document).ready(function () {
$.get("http://localhost:4916/DataAttribute", function (data, status) {
var selFields = new Object();
$.each(data, function (index, elem) {
selFields[elem.Name] = new Object();
selFields[elem.Name]["type"] = elem.Type;
});
$("#grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: { url: "http://localhost:4916/Deal",
dataType: "json"
}
},
schema: {
data: "Data", total: "Total",
model: {
fields: selFields
}
}
},
height: 430,
filterable: true,
sortable: true,
pageable: false,
detailTemplate: kendo.template($("#gridDetailTemplate").html()),
detailInit: detailInit,
columns: [{
field: "SecurityName",
title: "Security Name",
width: 250
},
{
field: "DateOfAcquisition",
title: "Date Of Acquisition",
width: 120,
format: "{0:MM/dd/yyyy}"
}, {
field: "Acres",
title: "Acres",
width: 120
}
]
});
});
});
function detailInit(e) {
$.get("http://localhost:4916/DataAttribute", function (data, status) {
var detailRow = e.detailRow;
detailRow.find(".edit-list").kendoListView({
dataSource: {
data: data,
schema: {
model: {
DataVal: function () {
switch (this.get("Type")) {
case "number"
}
if (e.data[this.get("Name")])
return e.data[this.get("Name")];
else
return '';
}
}
}
},
template: kendo.template($("#editItemtemplate").html())
});
});
}
</script>
My code gets dynamic field list and binds it to the data source for grid.
Then, in the detailInit event, I find the div within row detail and convert it into kendo UI list, for which the template have been created.
Now, when I use data-bind="value: DataVal()" ,it doesn't pick up the values of List data source. It works the way I have done i.e. value="#: DataVal() #". But, data-role does not convert the fields to specified types which are datepicker and numericinput in my case.
I believe that data-role not being used is caused due to same issue as data-bind not being read.
Can anyone help me out with this? Also, feel free to suggest any alternate ways and general code improvements. I am an ASP.NET developer and usually don't work on pure html and javascript.
PS: I would be happy to provide the context on what I am trying to achieve here if anyone is interested.
Thanks in advance.
If you can rig up a jsFiddle or jsBin example that would help debug the issue.
However, try removing the parenthesis:
data-bind="value: DataVal"
Kendo should detect that DataVal is a function and call it on its own.
I experienced a similar situation in a listview template. I created a JSFiddle to demonstrate:
http://jsfiddle.net/zacharydl/7L3SL/
Oddly, the solution is to wrap the contents of the template in a div. It looks like your template already has this, so YMMV.
<div id="example">
<div data-role="listview" data-template="template" data-bind="source: array"></div>
</div>
<script type="text/x-kendo-template" id="template">
<!--<div>-->
<div>method 1: #:field#</div>
<div>method 2: <span data-bind="text: field"></span></div>
<input data-role="datepicker" />
<!--</div>-->
</script>
var model = kendo.observable({
array: [
{ field: 'A'},
{ field: 'B'}
]
});
kendo.bind($('#example'), model);

Resources