I am trying to refactor my code and decided to re-implement my on events by mapping
Here's what i have:
$('img#sorc').on({
mousemove: function (e) {
alert('test in');
}
}, {
mouseleave: function () {
alert('test out');
}
});
Now mouseleave won't work.
I checked my code x10 and stared at it for so long, what did i miss?
You have additional }, { remove it with ,
$('img#sorc').on({
mousemove: function(e) {
alert('test in');
},
mouseleave: function() {
alert('test out');
}
});
Related
_initEventHandlers: function () {
if (this._isXHRUpload(this.options)) {
this._on(this.options.dropZone, {
dragover: this._onDragOver,
drop: this._onDrop,
// event.preventDefault() on dragenter is required for IE10+:
dragenter: this._onDragEnter,
// dragleave is not required, but added for completeness:
dragleave: this._onDragLeave
});
this._on(this.options.pasteZone, {
paste: this._onPaste
});
}
if ($.support.fileInput) {
this._on(this.options.fileInput, {
change: this._onChange
});
}
this code inside Jquery.fileupload.js but throw error:
this._on() is not a function
what can i do?
I am using the jquery-resizable plugin, and I need to inject some code as soon as users stop dragging the splitter. As soon as I add the onDragEnd event, I am not able to drag the handles anymore! I am using the onDragEnd function as listed on Git. Any idea why I am not able to catch that event?
onDragEnd: function () {
alert();
return false;
});
Fiddle: https://jsfiddle.net/mvg0vdm8/2/
Plugin: https://github.com/RickStrahl/jquery-resizable
You have a syntax error, try this:
onDragEnd: function () {
alert();
return false;
}
Complete script (from your fiddle):
$(document).ready(function() {
$(".panel-left").resizable({
handleSelector: ".splitter",
resizeHeight: false,
onDragEnd: function () {
alert();
return false;
}
});
$(".panel-top").resizable({
handleSelector: ".splitter-horizontal",
resizeWidth: false,
onDragEnd: function () {
alert();
return false;
}
});
});
I just would like to put color on div by addClass event and then it should fade in.
$("#box1").hover(
function () {
$("#box2").addClass("blue");
$("#box3").addClass("yellow");
},
function () {
$("#box2").removeClass("blue");
$("#box3").removeClass("yellow");
}
);
$("#box2").hover(
function () {
$("#box1").addClass("blue");
$("#box4").addClass("yellow");
},
function () {
$("#box1").removeClass("blue");
$("#box4").removeClass("yellow");
}
);
I know it's pretty ugly but it's worked :
$('#box1').hover(function () {
$("#box2").fadeOut(0).addClass('blue').fadeIn(300);
},
function () {
$("#box2").fadeOut(300).queue(function(){ $(this).removeClass('blue').fadeIn(0).dequeue()});
});
Demo here : JSFIDDLE
$('.imgc').hover(
function(e) {
$(this).effect("bounce", { times:5 }, "slow");
},
function(e) {
$(this).unbind('mouseenter');
});
I need to set an effect on the image. But I need this effect to work only at once. But then I need to bind again on mouseout. But it does not work.
('.imgc').bind('mouseenter', e);
How can I do this?
Try like
$('.imgc').on('hover', function(e) {
$(this).one(function () {
$(this).effect("bounce", { times:5 }, "slow");
});
$(this).off('mouseenter');
},
function(e) {
$(this).on('mouseenter');
});
You should try this,
$(".imgc").on({
mouseenter:function(){
$(this).effect("bounce", { times:5 }, "slow");
},
mouseleave:function(){
}
});
hover is basically a pseudoevent, which maps to mouseenter and mouseleave.
here's my call to the validate function. Everything works fine with this code.
$('#createForm').validate(function () {
});
But when I try to modify it a bit, the whole validation stop working:
$('#createForm').validate(function () {
errorPlacement: function(error, element) {
error.insertAfter(element);
},
debug:true
});
Any Idea?
you shouldn't have function() in there. change it to:
$('#createForm').validate(
{
errorPlacement: function(error, element) {
error.insertAfter(element);
},
debug:true
}
);
the stuff in the { } is the options. it's not a function :)
just remove function () in .validate(function () { and that should work...