The following code below is in CoffeeScript and after a couple of hours playing around with it and finally reading the documentation on WooThemes, I was able to get the Flexslider to append images correctly after clicking on my button to load the rest of the images from Instagram.
However, now when I click on the image, it isn't opening the Fancybox like the rest of the images that load on page load and was wondering if I could get some help here.
Slider =
flexi: ->
$('.flexslider').flexslider
animation: 'slide'
animationLoop: true
slideshow: false
itemWidth: 160
itemMargin: 5
minItems: 1
maxItems: 10
start: (slider) ->
$('#load-more').on 'click', (event) ->
event.preventDefault()
$.ajax
type: 'get'
url: $(this).find('a').attr('href')
dataType: 'jsonp'
success: (data) ->
$.each data.data, (index, value) ->
slider.addSlide '<li class="thumb" data-profile="' + value.user.profile_picture + '" data-lat="0" data-long="0" data-id="' + value.id + '" data-thumb="' + value.images.thumbnail.url + '" data-username="' + value.user.username + '" data-comments="' + value.comments.count + '" data-likes="' + value.likes.count + '" data-text="' + value.caption.text + '" data-link="' + value.link + '"><img alt="' + value.images.thumbnail.url.split('/')[3].split('.jpg')[0] + '" src="' + value.images.thumbnail.url + '" /></li>'
Fancy =
box: (lat, lng, pid) ->
street = undefined
latLng = new google.maps.LatLng lat, lng
view = new google.maps.StreetViewService()
$('.fancybox').fancybox
width: 1155
height: '95%'
maxWidth: '95%'
maxHeight: '95%'
openEffect: 'none'
autoSize: true
autoResize: false
closeEffect: 'fade'
scrolling: 'auto'
type: 'iframe'
helpers:
media:{}
beforeShow: ->
........
You can try wrapping the fancybox call with live() or on() or go and change the FancyBox source code to use the live() instead of regular bind() method. Here's sort of an untested code to give you a sense.
// on
$(document.body).on('click', '.fancybox', function() {
$(this).fancybox({ /* options */ }).trigger('click');
return false;
}
// live
$('.fancybox').live('click', function() {
$(this).fancybox({ /* options */ }).trigger('click');
return false;
}
Related
I am trying to load the documents on click of a button which is inside a grid but it is creating a new pages for every row and it is taking more time how to resolve it using kendo editor template or another specific methods.
// open window
function openWin(id) {
var myWindow = $("#" + id);
var did = id.replace("win", "doc");
console.log("Value from DID", did);
var rid = Number(id.replace("win", ""));
kendo.ui.progress($(".k-window"), true);
myWindow.data("kendoWindow").center().open();
$.ajax({
type: "POST",
url: "",
data: JSON.stringify(rid),
dataType: "json",
contentType: 'application/json; charset=utf-8',
success: function(data) {
kendo.ui.progress($(".k-window"), false);
$("#" + did).data("kendoEditor").value(data);
},
error: function() {
alert("Error occured!!");
}
});
}
// column definition
{
field: "Document",
template: docTemplateFunction,
title: "Document Intake",
width: "250px",
editable: "inline"
}
// template definition
function docTemplateFunction(dataItem) {
var input = '<div id="win' + dataItem.id + '"><textarea id="doc' + dataItem.id + '" style="width:100%;" aria-label="editor"></textarea></div><button class="k-button" onclick="openWin(' + "'win" + dataItem.id + "'" + ')">Open Doc</button><span class="k-button k-state-disabled doc-btn"><i class="red k-icon k-i-close k-state-disabled"></i></span>';
return input;
}
i try to make a Facebook Style User search using elastiquent on Laravel 5.5 that autocomplete ad sugest user by typing some char in input field.
The response from Ajax call return correct object but in my js code there is probably somethings wrong.
This the elasticsearch url http://basketmapp.com/users-list?q=Paolo, and in response i can see that item is correctly fetched:
this is the js used for selectize:
$(document).ready(function () {
var topUserSearch = $('.js-user-search');
if (topUserSearch.length) {
topUserSearch.selectize({
persist: false,
maxItems: 2,
valueField: 'name',
labelField: 'name',
searchField: ['name'],
options: [],
render: {
option: function(item, escape) {
return '<div class="inline-items">' +
(item.avatar ? '<div class="author-thumb"><img src="' + escape(item.avatar) + '" alt="avatar"></div>' : '') +
'<div class="notification-event">' +
(item.first_name ? '<span class="h6 notification-friend"></a>' + escape(item.first_name) + '</span>' : '') +
'</div>';
},
item: function(item, escape) {
var label = item.first_name;
return '<div>' +
'<span class="label">' + escape(label) + '</span>' +
'</div>';
}
},
load: function(query, callback)
{
if (!query.length) return callback();
$.ajax
({
url: '/users-list',
type: 'GET',
dataType: 'json',
data:
{
q: query
},
error: function()
{
callback();
},
success: function(res)
{
callback(res.data);
}
});
}
});
}
});
need your help!
Reading the docs it mentions "also containing the file list" in the paste options for the target element
http://docs.fineuploader.com/integrating/options/fineuploaderbasic.html
What is this? Is there a good example how to implement this? This is what I have so far. #pasteimage is a text box.
Using Chrome 10.6 Do I need to turn it on somewhere in jquery.fineuploader-3.4.1.js
$(document).ready(function(){
var thumbnailuploader = new qq.FineUploader({
element: $('#thumbnail-fine-uploader')[0],
request: {
endpoint: '/Admin/CFC/image-uploader.cfc?method=Upload',
params: {
profileID: '<cfoutput>#profile.ID#</cfoutput>',
profileType:'<cfoutput>#profile.Profile_Type#</cfoutput>',
subDName:'<cfoutput>#DecodeforHTML(profile.Subdomain_Name)#</cfoutput>'
},
},
multiple: true,
validation: {
allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
sizeLimit: 102400, // 100 kB = 100 * 1024 bytes
itemLimit: 1,
stopOnFirstInvalidFile: false
},
text: {
uploadButton: "\+ Click or Drop"
},
paste:{
targetElement:$('#pasteimage')
},
callbacks: {
onComplete: function(id, fileName, responseJSON){
if (responseJSON.success) {
$('#thumbnail-fine-uploader').append('<img src="/<cfoutput>#profile.Profile_Type#</cfoutput>/<cfoutput>#profile.ID#</cfoutput>/' + responseJSON.filename + '" alt="' + fileName + '" style="width:120px;height:120px;">');
$('#thumbnail-fine-uploader').append('<br/><b style="color:red;">' + responseJSON.returnedProfileID + '<br/>'+ responseJSON.returnedprofileType+'<br/>'+responseJSON.returnedsubDName+'</b>');
}
}
},
onUpload: function(id, fileName){
$('#file-' + id).addClass('alert-info').html('<img src="/Images/loading.gif" alt="Initializing. Please hold."> ' +
'Initializing ' +
'“' +
fileName +
'”');
},
onProgress: function(id, fileName, loaded, total){
if (loaded < total) {
progress = Math.round(loaded / total * 100) + '% of ' + Math.round(total / 1024) + ' kB';
$('#file-' + id).removeClass('alert-info').html('<img src="/Images/loading.gif" alt="In progress. Please hold."> ' +
'Uploading ' +
'“' +
fileName +
'” ' +
progress);
}
else {
$('#file-' + id).addClass('alert-info').html('<img src="/Images/loading.gif" alt="Saving. Please hold."> ' +
'Saving ' +
'“' +
fileName +
'”');
}
},
})
});
The paste target element can be any container that will receive the pasted image(s). This is where your users will paste any image on their clipboard. There isn't much to demonstrate. Simply create an element in the DOM, preferably one that your users can understand is the location where images can be pasted. Then, set this element as the value of the paste option's targetElement property. You can even use the document as a target, if you want.
I'm calling inline html in ColorBox and it shows no content in IE8. This can be replicated on Jack Moores own site. Simply goto the demo site, http://www.jacklmoore.com/colorbox/example1/ , then click the second to the last link "Inline HTML". Then click the bottom link to update content ... in IE8 the box shows nothing.
I'm having the same problem, but I'm creating the div collection on the fly as shown below. Its for a check box confirmation. Any suggestions?
$('input[name$=chkApproved]').click(function (e) {
var th = $(this);
if (th.is(':checked')) {
var dialog = '<div">'
+ '<div id="dialog">'
+ '<p style="margin-top: 30px;">'
+ 'Are you sure you want to approve this program?</p>'
+ '<p style="font-size: small;">'
+ '<strong>Note:</strong> This cannot be undone!</p>'
+ '<p style="text-align: center;">'
+ 'Approve'
+ ' '
+ 'Cancel'
+ '</p></div></div>';
$.colorbox(
{
onLoad: function() {
$("#cboxClose").remove();
},
overlayClose: false,
href: dialog,
open: true,
title: "Program Approval",
inline: true,
height: "210px",
onClosed: function () {
$("[id$=btnHiddenApprove]").click();
}
});
e.stopPropagation();
} else {
th.attr('checked', false);
}
});
The problem on my page was a broken link. Just fixed that, so it shouldn't be a problem. That wasn't specific to IE8, and I haven't had any troubles with IE8.
The only problem I see with what you posted is that you have a stray quote mark in the opening <div> element. I checked your content in IE8 and that was indeed the issue:
This:
var dialog = '<div">'
Should be this:
var dialog = '<div>'
The stray quote mark makes your markup not well formed, and it's up to the browser how they want to respond or recover from the error, leaving for very inconsistent results.
Here is the revised code for who ever is interested .... this code will show a confirmation on a check-box, and uncheck it if cancel is selected. The onClosed event fires a hidden button click event that goes through the gridview and sets any checked check-boxes.
function UnCheckBox(cb) {
//alert(cb);
$('#' + cb + '').removeAttr('checked');
}
$(document).ready(function () {
$('input[name$=chkApproved]').click(function (e) {
var th = $(this);
if (th.is(':checked')) {
var dialog = '<div>'
+ '<div id="dialog">'
+ '<p style="margin-top: 30px;">'
+ 'Are you sure you want to approve this program?</p>'
+ '<p style="font-size: small;">'
+ '<strong>Note:</strong> This cannot be undone!</p>'
+ '<p style="text-align: center;">'
+ 'Approve'
+ ' '
+ 'Cancel'
+ '</p></div></div>';
$.colorbox(
{
onLoad: function() {
$("#cboxClose").remove();
},
href: dialog,
open: true,
title: "Program Approval",
inline: true,
height: "210px",
onClosed: function () {
$("[id$=btnHiddenApprove]").click();
}
});
e.stopPropagation();
} else {
th.attr('checked', false);
}
});
After uploading a file, before I save it on the disk, I'm doing some validation.
If something fails, I want to show my custom error message to the user.
I've found something sililar here Uploadify: show error message from HTTP response
How to do this in MVC 3 ?
Tony,
Taken straight from ab mvc3 app that I'm working on right now:
<script type="text/javascript">
function initupLoadify() {
$("#fileInput").uploadify({
uploader: '#Url.Content("~/scripts/swf/uploadify.swf")',
script: '#Url.Action("Upload", "Home")',
cancelImg: '#Url.Content("~/Content/cancel.png")',
auto: true,
sizeLimit: 5500000,
fileDataName: 'fileData',
//scriptData: { 'propertyId': $("#PropertyID").val() },
buttonText: 'Add Schedule',
wmode: 'transparent',
//buttonImg: '#Url.Content("~/Content/button.png")', // make nice gradient image for button
onComplete: function (event, queueId, fileObj, response) {
$("#msg").html(response);
// do something
setTimeout(2000, window.location = '#Url.Action("Index")' + '?id=' + response);
return true;
},
onCancel: function (evt, queueId, fileObj, data) {
$("#msg").html("<br />Operation cancelled");
return true;
},
onOpen: function (evt, queueId, fileObj) {
$("#msg").html("<br />Upload in progress");
return true;
},
onError: function (event, queueId, fileObj, errorObj) {
$("#msg").html(fileObj.name + " was not uploaded ");
if (errorObj.status == 404)
$("#msg").html("Could not find upload script. Use a path relative to: " + "<?= getcwd() ?>");
else if (errorObj.type === "HTTP")
$("#msg").html("error " + errorObj.type + ": " + errorObj.status);
else if (errorObj.type === "File Size")
$("#msg").html(fileObj.name + " " + errorObj.type + " Limit: " + errorObj.info / 1000 + " KB");
else
$("#msg").html("error " + errorObj.type + ": " + errorObj.text);
}
});
};
</script>
hope this helps
Here is an MVC 3 example.
If you're using versions 3.0+ use onUploadComplete instead of onComplete (realize their parameters differ).