Table Focus event is not working in IE - javascript

I am using one event "tableFocusEvent" in YUI. It's working fine in FF but it's not working in IE.I tried to get similar event and use "focus" but that also not working.
Can anyone Please help me in this. Any help is appriciated.
My code is here
myDataTable.subscribe('tableFocusEvent', test);
function test()
{
alert("Hii");
}

Kailash you can try this one I think this must be helpful.You have mentioned in your question that you have used focus event please check below code have you used like this way -
var items = Y.one('#items');
items.on('focus', function (e) {
Y.log("testing for focus event");
});

Related

how to use "selection" event listener on autoComplete javascript library

I've been spending the last few days trying to figure out how to use TarekRaafat's autoComplete.js on one of my input box. my current problem is, when I click one of the options, nothing happens. here's what I tried: https://jsfiddle.net/vjyLagh8/14/
the console.log in 'selection' event are not called
autoCompleteJS.input.addEventListener("selection", function (e) {
console.log('selection detail'); // ==> this doesn't appear in dev tools
// ...
});
I'm doing it exactly like in the codepen example but why is my code not working? what am I doing wrong?
any help is appreciated..
This is a bit late but the event is called "select", not "selection"
autoCompleteJS.input.addEventListener("select", function (e) {
console.log('This works');
});

JQuery click() event listener not working

im trying to get a lil project going but im stuck on a very annoying thing.
$(document).ready(function() {
$("#search-button").click(console.log('hello'))
});
as you can see im targeting a search button with the id search-button and as soon as i click it something should happen. in this case i put a console.log in to test if it works but it doesn't. it always logs it as soon as i load the page , not when i click the button i target. ... what am i doing wrong
if you need more info on this pls tell me i tried to keep it as simple as i could
ty for your help
O.k
The click handler needs a function argument, not just the console.log by itself. Try this:
$(document).ready(function() {
$("#search-button").click(function() {
console.log('hello');
});
});
Inside of .click should be a handler .click(handler) and the handler should be a function. The browser is reading the code and when it hits console.log('hello'), it does it! It's seeing .click etc, but it doesn't matter; it next sees console.log and does it.
Try
$(document).ready(function() {
$("#search-button").click(function() {
console.log('hello');
});
});
As others have mentioned, the click function requires its own callback function. You can also use this, without requiring the use of document:
$("#search-button").on('click', function() {
console.log('hello')
})
I hope You're using jQuery version 3 or up. if you use 3 or up jquery version the good practice is you use Document binding Example:
jQuery(document).on('click', '#search-button', function(event) {
//your Code here...
console.log('hello');
});

blur event doesn't trigger at first attempt

I'm trying to update the DOM based on the value entered in a text box.
HTML:
<input id="event-name" type="text"/>
JQUERY:
$('#event-name').on('blur',function(){
$.post("scripts/add-team-support.php",{eventName : eventName},function(minAndMaxString){
//my code here
});
});
this works on the first blur in Chrome. When I tried it in opera, mozilla and edge it doesn't worked on the first attempt.
It worked when I added this before the jquery.
$("#event-name").focus();
$("#event-name").blur();
$("#event-name").focus();
I did this to make the first $.post call to occur when the page opens.
Why is this problem happening?
How to solve this in a proper way?
Please help!
You can try this code:
var lazyTriggerEvent = function(id,event,callback){
var searchTrigger=null;
$("#"+id).bind(event,function(){
var text = $.trim($(this).val());
clearTimeout(searchTrigger);
searchTrigger = setTimeout(function(){
callback(text);
},500);
})
};
//use keyup event
lazyTriggerEvent("event-name","keyup",function(){})
It often happens with elements across browsers that consequent events do not work when binding an event to them through ID or class. The following solution should help you:
$(document).on('blur','#event-name', function(){
$.post("scripts/add-team-support.php",{eventName : eventName},function(minAndMaxString){
//my code here
});
});
Alternatively, you could use keyup event. You can do so following:
$(document).on('keyup','#event-name', function(){
var eventName = $(this).val();
$.post("scripts/add-team-support.php",{eventName : eventName},function(minAndMaxString){
//my code here
});
});
Also, using - in IDs is not a good approach. Rather, either stick to camelCase or underscore_format of naming convention.

Only buttons on first page of table are clickable when using pagination - List.js

I recently asked a question about the inability to click a table row and popup an alert when on any page but the first using List.js pagination.
This was solved by adjusting my click event to:
$('#test-list').on('click', 'tr', function() {
alert("These work, but the rest don't :(")
})
Now I seem to be having the same trouble with buttons, but am not sure how to fix the click event.
This is the click event as it sits:
$(".test-button").on("click", function ()
{ alert("These work, but the rest don't :(");
});
Here's a codepen so you can check out the issue:
http://codepen.io/cavanflynn/pen/gpdgvj
It's probably also a simple fix, but I cannot come up with the solution.
Thanks for your help!
for the buttons use a static reference to bind the event and then pass the button class like this:
$("#test-list tbody").on("click", ".test-button",function () {
alert("These work, but the rest don't :( ..... but now seems working :) ");
});
working pen http://codepen.io/anon/pen/XbPpPK

Triggering a change event for Internet Explorer

I have several select menus that needs that need to have their change events triggered on page load, so that they can automatically use the change behavior from an on('change', ...) handler.
I have it working fine in Firefox, but apparently this doesn't work in Internet Explorer.
Example
var changeEvent = new Event('change')
input.dispatchEvent(changeEvent);
I have tried finding alternatives in IE, and this is the closest I've come:
ie_event = document.createEvent('change')
ie_event.initEvent('change', function(e) {
...
}, false);
document.dispatchEvent(ie_event);
*The above is from codeproject.com, but it doesn't tell me what to put in the ellipses.
Can someone tell me what's wrong, point me in the right direction, or give me an example?
Would this be of any help?
<script>
$(document).ready(function () {
$("#select").on("change",function(){
//do something
});
$("#select").trigger("change");
});
</script>

Categories

Resources