jQuery Animate or Load function not working in IE11 - html

$(document).ready(function () {
$("img#ucar").load(function () {
$(this)
.animate({ opacity: 1 / 2 }, 600)
.animate({ top: "616px" }, 300)
.animate({ opacity: 1 }, 0);
return false;
});
});
.ism {
top: -400px;
width: 225px;
height: 345px;
margin: 0;
padding: 0;
position:absolute;
}
#ucar {
position: relative;
}
<div class="ism">
<img id="ucar" src="images/img01.png" />
</div>
This code is working chrome but not working IE 11. I looked at other questions only answer I could not find on the site.

This happens mainly to cached images that get loaded (due to the caching) before the script has time to execute.
Add a check to see if the image is already loaded and trigger the script..
$(document).ready(function () {
$("img#ucar").load(function () {
$(this)
.animate({ opacity: 1 / 2 }, 600)
.animate({ top: "616px" }, 300)
.animate({ opacity: 1 }, 0);
return false;
}).each(function(){
if (this.complete){
$(this).trigger('load');
}
});
});
Demo at http://jsfiddle.net/gaby/k7vz0dgv/

It seems that the .load() function is not triggered in IE for some reason.
You could manually trigger the event by telling the image to load an empty string "" so once its done, the callback function will execute:
$(document).ready(function () {
// have a look at the load function
$("img#ucar").load("",function () {
$(this).animate({
opacity: 1 / 2
}, 600).animate({
top: "616px"
}, 300).animate({
opacity: 1
}, 0);
return false;
});
});
Fiddle Example

Related

Can't put size of calendar to occupy all the width using fullcalendar

This is how the calendar appears
This is my code
<div id='calendar' ></div>
<script>
$(function () {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,agendaWeek,agendaDay'
},
aspectRatio: 1,
initialView: 'dayGridMonth',
editable: true,
eventLimit: true, // allow "more" link when too many events
dayClick: function () {
alert('a day has been clicked!');
},
events: 'https://fullcalendar.io/demo-events.json'
});
});
</script>
#calendar {
max-width: 900px;
margin: 40px auto;
padding: 0 10px;}
I'm using Flask with jquery
What do I need to do? I didn't found anyone else with this problem

Jquery 'click' function only works on the "if" statement, not the "else if" [duplicate]

This question already has answers here:
Why do I get different results with "=" vs. "===" in javascript with Conditional (Ternary) Operators?
(4 answers)
Closed 1 year ago.
first post, im trying to make a slide menu of some kind, and although it works clicking once and letting the menu options come forth. clicking again results in redoing the opening animation, instead of subtracting them back to their first location.
let menuopen = false;
$(document).ready(function(e) {
$("#menu_button").on('click',function(e) {
if (menuopen == false) {
$("#menu_button").css({"left":"500px"}).animate({left: '450px'})
$("#menu_select").css({"left":"500px"}).animate({left: '750px'});
$("#menu_select_two").css({"left":"500px"}).animate({left: '1050px'});
menuopen == true;
}
else if (menuopen == true) {
$("#menu_button").css({"left":"450px"}).animate({left: '500px'})
$("#menu_select").css({"left":"750px"}).animate({left: '500px'});
$("#menu_select_two").css({"left":"1050px"}).animate({left: '500px'});
menuopen == false
}
});
});
You are not assigning
menuopen == true;
should be
menuopen = true;
In any case: Why else if, just use else?
Try this - it saves the state in the button
You COULD use a ternary but that would be messy in this case
$(function(e) {
$("#menu_button").on('click',function(e) {
const menuopen = !!$(this).data("open"); // force boolean
if (menuopen) {
$("#menu_button").css({"left":"450px"}).animate({left: '500px'})
$("#menu_select").css({"left":"750px"}).animate({left: '500px'});
$("#menu_select_two").css({"left":"1050px"}).animate({left: '500px'});
}
else {
$("#menu_button").css({"left":"500px"}).animate({left: '450px'})
$("#menu_select").css({"left":"500px"}).animate({left: '750px'});
$("#menu_select_two").css({"left":"500px"}).animate({left: '1050px'});
}
$(this).data("open",!menuopen)
});
});
Perhaps
const butOpen = { "left": "450px" },
butClosed = { "left": "500px" },
selectOpen = { "left": "750px" },
selectClosed = { "left": "500px" },
select2Open = { "left": "1050px" },
select2Closed = { "left": "500px" }
$(function(e) {
$("#menu_button").on('click', function(e) {
const menuopen = !!$(this).data("open"); // force boolean
$("#menu_button").css(menuopen ? butOpen : butClosed).animate(menuopen ? butClosed : butOpen)
$("#menu_select").css(menuopen ? selectOpen : butClosed).animate(menuopen ? selectClosed : selectOpen)
$("#menu_select_two").css(menuopen ? select2Open : select2Closed).animate(menuopen ? select2Closed : select2Open)
$(this).data("open", !menuopen)
});
});
Or use a class and toggle it:
window.addEventListener("load", function(e) {
const wrapper = document.querySelector(".wrapper");
document.getElementById("menu").addEventListener("click", function(e) {
wrapper.classList.toggle("open");
this.textContent = wrapper.classList.contains("open") ? "Close" : "Open";
})
})
.wrapper {
position: relative;
overflow: hidden;
width: 100px;
height: 100px;
border: 1px solid black;
}
#slide {
position: absolute;
left: -100px;
width: 100px;
height: 100px;
background: blue;
transition: 1s;
}
.wrapper.open #slide {
transition: 1s;
left: 0;
}
<button id="menu" type="button">Open</button>
<div class="wrapper">
<img id="slide" src="https://lorempixel.com/output/cats-q-c-100-100-4.jpg" />
</div>

Making Input Text to open up drop down list in AngularJS

I am trying to create a directive in AngularJS which acts as Input and Select box together. Just like when you type in search textbox a dropdown list popups for assisting user to select. The selection is working fine via mouseclick, but I want my user to use arrow keys to move up and down and select on enter as well. Below is my HTML , CSS and Javascript code. Your quick assistance in this regard will be appreciated.
/*******CSS Code******/
.input-dropdown {
position: relative;
display: inline-block;
}
.input-dropdown .dropdown {
display: none;
position: absolute;
top: 100%;
left: 0;
width: 100%;
margin-top: 2px;
background: #EEE;
}
.input-dropdown .dropdown div {
cursor: pointer;
padding: 2px 5px;
}
.input-dropdown input:focus + .dropdown {
display: block;
}
/*******AngularJS Code*****************/
var app = angular.module('myApp', []);
app.controller('MainCtrl', function ($scope) {
$scope.values = ['Chrome', 'Firefox', 'IE'];
$scope.pick = function (value) {
console.log('Picked', value)
};
});
app.directive('inputDropdown', function ($compile) {
var template =
'<input ng-model="ngModel">' +
'<div class="dropdown">' +
'<div ng-repeat="value in list | filter: ngModel">' +
'<div ng-mousedown="select($event, value)">{{value}}</div>' +
'</div>' +
'</div>';
return {
restrict: 'EA',
scope: {
ngModel: '=',
list: '=',
onSelect: '&'
},
template: template,
link: function (scope, element, attrs) {
element.addClass('input-dropdown');
scope.select = function (e, value) {
scope.ngModel = value;
scope.onSelect({ $event: e, value: value });
};
}
};
});
HTML Code:
<html ng-app="myApp">
<head>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body ng-controller="MainCtrl">
<input-dropdown ng-model="preference" list="values" on-select="pick(value)"></input-dropdown> {{preference}}
</body>
</html>

show loading image on directive call on page load and ajax calls in AngularJS

I want to show image on page load and ajax calls.So that i created a directive "lodder". In html page when i am using it is showing the alert ("hi direvtive"). but in detailscontroller.js i have written that $scope.loadingStatus=true so it should show the img but it is not displaying .
-------------angular.js-------------
var app= angular.module('myApp', ['ngRoute', 'ngAnimate', 'angular-ladda', 'ui.bootstrap', 'uiSlider', 'ngCookies']);
app.directive('lodder', function () {
alert("hi direvtive");
var directive = {
restrict: 'A',
template: '<div style="margin: 0px; padding: 0px; position: fixed; right: 0px; top: 0px; width: 100%; height: 100%; background-color: rgb(102, 102, 102); z-index: 30001; opacity: 0.8;" ><p style="position: absolute; color: White; top: 50%; left: 50%;"><img src="http://localhost:60792/img/ajax-loader1.gif" ></p></div>',
link: function (scope, element, attr) {
scope.$watch('loadingStatus', function (val) {
if (val)
$(element).show();
else
$(element).hide();
});
}
};
return directive;
});
------------------html page------------
<div class="content" ng-controller="detailsController" >
<lodder />-------------this is my directive
--------------------detailsController.js------------
var urlPrefix ='';
function GetUsers() {
$scope.loadingStatus = true;
$http({
method: 'POST',
url: urlPrefix + '/Dashboard/GetUsers',
contentType: "application/json; charset=utf-8",
dataType: "json"
}).success(function (results) {
$scope.userslist = JSON.parse(results.userslist);
$scope.loadingStatus = false;
})
.error(function (results) {
$scope.error = "An Error has occured while loading posts!";
$scope.loadingStatus = false;
});
};
GetUsers();
----------------------------finish------------------

cannot hover with new div of fancybox 2

I've made it work by these codes for an addtional title (a new div inside fancybox):
beforeShow: function(){
this.title=$(this.element).data('caption');
this.title2="<div class='photo_exif'>"+$(this.element).data('exif')+"</div>";
$(this.title2)
.bind("contextmenu", function (e) {
return false; /* Disables right click */
})
.prependTo( $.fancybox.inner );
}
and the html is :
<a href='PhotoURL' class='fancybox' data-fancybox-group='gallery' data-caption='PhotoTitle' data-exif='photoTitle2'>pic</a>
now i want this div (div.photo_exif) hover to show or hide, so i added these codes:
afterShow:function() {
$("#fancybox-wrap").hover(function() {
$(".photo_exif").show();
}, function() {
$(".photo_exif").hide();
});
}
but it doesnt work. The div is always show on fancybox. My css is :
.photo_exif {
position: absolute;
bottom: 0;
left: 0;
color: #fff;
width:100%;
height:30px;
background: #000;
background: rgba(0, 0, 0, .8);
}
and my whole fancybox code (with ie6 crack) is :
$('.fancybox').fancybox({
fitToView: false,
mouseWheel: false,
beforeShow: function(){
this.title=$(this.element).data('caption');
this.title2="<div class='photo_exif'>"+$(this.element).data('exif')+"</div>";
$(this.title2)
.bind("contextmenu", function (e) {
return false; /* Disables right click */
})
.prependTo( $.fancybox.inner );
},
afterShow: function(){
if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) <= 6) {
$("div#fancybox-buttons").css("top", $("html").scrollTop());
$(window).scroll(function () {
$("div#fancybox-buttons").css("top", $("html").scrollTop());
});
}
$("#fancybox-wrap").hover(function() {
$(".photo_exif").show();
}, function() {
$(".photo_exif").hide();
});
}
});
Is there anything wrong?
This one was easy. This line of your code :
$("#fancybox-wrap").hover(function() {
... should be :
$(".fancybox-wrap").hover(function() {
The fancybox selector is a class not an ID