Search Results

Search found 10381 results on 416 pages for 'delegate and events'.

Page 109/416 | < Previous Page | 105 106 107 108 109 110 111 112 113 114 115 116  | Next Page >

  • When designing an event, is it a good idea to prevent listeners from being added twice?

    - by Matt
    I am creating an event-based API where a user can subscribe to an event by adding listener objects (as is common in Java or C#). When the event is raised, all subscribed listeners are invoked with the event information. I initially decided to prevent adding an event listener more than once. If a listener is added that already exists in the listener collection, it is not added again. However, after thinking about it some more, it doesn't seem that most event-based structures actually prevent this. Was my initial instinct wrong? I'm not sure which way to go here. I guess I thought that preventing addition of an existing listener would help to avoid a common programming error. Then again, it could also hide a bug that would lead to code being run multiple times when it shouldn't.

    Read the article

  • Javascript Event for Select element Selection

    - by JP
    Hi everyone, I'm looking to find the Javascript Event I need to put into jQuery's .bind function in order to have the function triggered when a selection is made from a <select> element. At the moment I'm using .bind('change',function() { ...}) but I need the event to trigger when the selected option is chosen again. Any suggestions?

    Read the article

  • IE event for right-click delete on <input> or <textarea>

    - by Jayraj
    What event is fired when you right-click on selected text in an <input> or <textarea> tag and the click "Delete" in Internet Explorer (I'm targeting version 9, but if it's good for lower versions too, all the better). On other browsers , the "input" event appears to work for all text changes through right-click so doing $("textarea").on("input", function() {...}); works. IE works for cut and paste, but not delete (JSFiddle here) although MDN claims that IE is supported.

    Read the article

  • Event in Global.asax file that fires only for once

    - by fiberOptics
    In MVC Global.asax file, we can see the Application_Start where this event fires only for once. But the session is not yet active/available here. So my question is, is there any event in Global.asax file that fired only for once and session is available also? The reason I ask this is because, I use ExpandoObject e.g.: public static dynamic Data { get { #region FAILSAFE if (HttpContext.Current.Session[datakey] == null) { HttpContext.Current.Session[datakey] = new ExpandoObject(); } #endregion return (ExpandoObject)HttpContext.Current.Session[datakey]; } } I want to initialize all of my ExpandoObject at once with the value of null: MyExpando.Data.UserInformation = null; MyExpando.Data.FolderInformation = null; That's why I'm looking for an event that only fired once.

    Read the article

  • .focus() doesn't work on an input while orher attributes works

    - by Sirber
    I have a classic table / thead / tbody structure, which I add a line at the end of the tbody. The line contains only an input element. The code works in Firefox 3.6 but not in Chrome v5 or IE8. I'm using jQuery 1.4.1. Does not work: $("#" + AJAX_ID).parent().find('tr:last > td:nth-child(2) > input').focus(); Does work: $("#" + AJAX_ID).parent().find('tr:last > td:nth-child(2) > input').css('background-color', 'red'); even setting an ID on the input, and using document.getElementBuId('id').focus() doesn't work. Thank you!

    Read the article

  • JQuery UI (1.8) Select Event not working on Autocomplete

    - by Cyril Gupta
    I am trying to use JQuery UI autocomplete (1.8) for an app. It is set up like this: $('#txtigtags').autocomplete({ serviceUrl: '/tags/searchtags' + $('#txtigtags').val(), minChars: 2, delimiter: ' ', select: function () { alert(''); }, deferRequestBy: 500 }); According to the documentation the select event should fire whenever an entry is selected in the drop-menu and I should get the alert. But the select event is not firing at all. Neither is focus. What am I doing wrong?

    Read the article

  • Restricting numeric input javascript problem

    - by neitony
    I'm trying to figure out why my javascript code is not restricting numeric input. Here's the code below: (function(){ if(window.addEventListener) window.addEventListener("load",init,false); else if(window.attachEvent) window.attachEvent("onload",init); function init() { var keytest = document.getElementById("keytest"); function numericinput(event) { var e = event || window.event; var key = e.charcode || e.keyCode; var regex =/^\d+\.?\d{4}$/; key = String.fromCharCode(key); if (!regex.test(key)) { alert("something"); //if(e.preventDefault) e.preventDefault(); //if(e.returnValue) e.returnValue = false; //return false; } else { //return true; alert("something else"); } } if(keytest.addEventListener) keytest.addEventListener("keypress",numericinput,false); else { keytest.onkeypress = numericinput(); } } })();

    Read the article

  • Bind an event handler to multiple elements jQuery?

    - by Alex
    Hello all. I've done some experimenting, but can't seem to successfully bind one event handler to multiple elements using jQuery. Here's what I've tried: $('selector1', 'selector2').bind('click', function() { $('someSelector').removeClass('coolClass'); }); I've tested all my selectors, and they are all valid. Is what I'm trying to do even possible? If so, can I do it with .live() as well? Thanks!

    Read the article

  • onclick event is not fire in google chrome

    - by purnang.advant
    I am trying to fire the asp.net button click event from javascript. Its working fine in IE, but the same code is not working on Chrome, please help me. Here is the js code, var btnSave = document.getElementById('btnSave'); btnSave.click(); alert("The changes are saved sucessfully!!"); Please help me

    Read the article

  • jquery "this" binding issue on event handler

    - by clyfe
    In jquery an event hadler's binding is the event generating DOM element (this points to the dom element). In prototype to change the binding of an event handler one can use the bindAsEventListener function; How can I access both the instance and the DOM element from a event handler? Similar to http://stackoverflow.com/questions/117361/how-can-i-bind-an-event-handler-to-an-instance-in-jquery function Car(){ this.km = 0; $("#sprint").click(this.drive); //setup event handler } // event handler // in it I need to access both the clicked element // and the binding object (instance of car) Car.prototype.drive = function(){ this.km += 10; // i'd like to access the binding (but jq changes it) this.css({ left: this.km }); // also the element // NOTE that is inside this function I want to access them not elsewhere } var car = new Car();

    Read the article

  • How to cancel click event of container div trigger when click elements which inside container in JQuery!?

    - by qinHaiXiang
    E.g <div class="container"> <div class="inside">I am not fire when click me</div> </div> $('.container').click(function(){ // container do something here }); but,when I click the div inside it also trigger the container's click event because the div is inside the container, so , I need a way to prevent the container event trigger when I click on the inside div! Thank you very much!!

    Read the article

  • Click event not registering on second page.

    - by Cptcecil
    I'm using tablesorter and tablesorter.pager. Here is my code. $(document).ready(function() { $("#peopletable") .tablesorter({ widthFixed: true, widgets: ['zebra'] }) .tablesorterFilter({ filterContainer: $("#people-filter-box"), filterClearContainer: $("#people-filter-clear-button"), filterColumns: [1, 2, 3], filterCaseSensitive: false }) .tablesorterPager({ container: $("#peoplepager") }); $("#peopletable tr.data").click(function() { var personid = $(this).attr('id'); $.ajax({ type: "POST", url: "/Search/GetDocumentsByPerson", data: { "id": personid }, datatype: "json", success: function(data) { var results = eval(data); $("#documentstable > tbody tr").remove(); $.each(results, function(key, item) { $("#documentstable > tbody:last").append(html); }); $("#documentstable").trigger("update"); } }); }); }); Everything works great except when I click on the next page my button click event doesn't fire. Is this a known issue with jquery tablesorter?

    Read the article

  • How to add a cross-browser mouse wheel function to a div in javascript?

    - by Shaunwithanau
    I am trying to stop the default mouse wheel event that is called on the window and on a div and call my own function instead on the div. I need this to be cross-browser (without the use of a library. I know I need to use an eventListener and I think have to use both onmousewheel and DOMMouseScroll (for FF) but I think am getting caught up in the implementation somewhere. I appreciate any and all help.

    Read the article

  • Problem with DataGrid_CellFormatting event to set default value

    - by Royson
    Hi, I have created an applicationto display list of files. it also provide user interface for adding new column to a gridview. DataGridViewTextBoxColumn txtBoxColumn = new DataGridViewTextBoxColumn(); txtBoxColumn.Name = columnName; txtBoxColumn.HeaderText = columnName; g_dataGridView.Columns.Add(txtBoxColumn); User will create some custom type column therefore i am adding column directly to grid. I am also able to set its default value before adding for this i am using DataGrid_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e) { if (colIndexWithDefaultValue.Count > 0) { if (colIndexWithDefaultValue.Contains(e.ColumnIndex)) { g_dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = colIndexWithDefaultValue[e.ColumnIndex]; } } } where colIndexWithDefaultValue is list of columns with its default value. It is able to show newly created column with default value. But values are getting set for currently visible rows. To set value for all rows i have to do scrolling. So, how do i overcome this problem...

    Read the article

  • HTML form with single text field + preventing postback in Internet Explorer

    - by SudheerKovalam
    I have noticed a rather strange behaviour in IE. I have a HTML form with a single input text field and a submit button On Submit click I need to execute a client side JavaScript function that does the necessary. Now when I want to prevent the postback in the text field (on enter key press) I have added a key press JavaScript function that looks like this: <input type=text onkeypress="return OnEnterKeyPress(event)" /> function OnEnterKeyPress(event) { var keyNum = 0; if (window.event) // IE { keyNum = event.keyCode; } else if (event.which) // Netscape/Firefox/Opera { keyNum = event.which; } else return true; if (keyNum == 13) // Enter Key pressed, then start search, else do nothing. { OnButtonClick(); return false; } else return true; } Strangly this doesn't work. But if I pass the text field to the function : <input type=text onkeypress="return OnEnterKeyPress(this,event);" /> function OnEnterKeyPress(thisForm,event) { var keyNum = 0; if (window.event) // IE { keyNum = event.keyCode; } else if (event.which) // Netscape/Firefox/Opera { keyNum = event.which; } else return true; if (keyNum == 13) // Enter Key pressed, then start search, else do nothing. { OnButtonClick(); return false; } else return true; } I am able to prevent the postback. Can anyone confirm what is exactly happening here?? the HTML form has just one text box and a submit button The resultant o/p of the JavaScript function executed on submit is displayed in a HTML text area in a separate div.

    Read the article

  • Form Search Onkeyup event

    - by Aryan
    I Have a Form In which the form should automatically search when i complete entering the 10th character in the text field but the below code is searching for each n every character i enter in the text field . . . I just want the result after completing the 10th character not for each n every character . . i have used onkeyup event and i set that value to 10 but still it is searching for each n every character... please do help me <body OnKeyPress="return disableKeyPress(event)"> <section id="content" class="container_12 clearfix" data-sort=true> <center><table class='dynamic styled with-prev-next' data-table-tools='{'display':true}' align=center> <script> function disableEnterKey(e) { var key; if(window.event) key = window.event.keyCode; //IE else key = e.which; //firefox return (key != 13); } function showUser(str) { if (str=="") { document.getElementById("txtHint").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("txtHint").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","resdb.php?id="+str,true); xmlhttp.send(); } </script> <script type='text/javascript'> //<![CDATA[ $(window).load(function(){ $('#id').keyup(function(){ if(this.value.length ==10) }); });//]]> </script> <form id="form" method="post" name="form" > <tr><td><p align="center"><font size="3"><b>JNTUH - B.Tech IV Year II Semester (R07) Advance Supplementary Results - July 2012</b></font></p></td></tr> <td><p align="center"><b>Last Date for RC/RV : 8th August 2012</b></p></td> <tr><td><p align="center"></b> <input type="text" onkeyup="showUser(this.value)" onKeyPress="return disableEnterKey(event)" data-type="autocomplete" data-source="extras/autocomplete1.php" name="id" id="id" maxlength="10" placeholder=" Hall-Ticket Number">&emsp;</p></td></tr> </table> </center> </form> <center> <div id="txtHint"><b>Results will be displayed here</b></div> </center> </body>

    Read the article

< Previous Page | 105 106 107 108 109 110 111 112 113 114 115 116  | Next Page >