Search Results

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

Page 103/416 | < Previous Page | 99 100 101 102 103 104 105 106 107 108 109 110  | Next Page >

  • Detecting DOM event support in Firefox

    - by Andy E
    What's the best way to detect event support in Firefox. Opera, Internet Explorer and Safari/Chrome all support eventName in object, but Firefox doesn't. My test case is this: javascript:alert("onclick" in document.createElement("a")) Which alerts true when entered into the address bar on the aforementioned browsers, and alerts false for Firefox. I figured out a solution using typeof on an event like so: var a = document.createElement("a"); a.setAttribute("onclick", ""); alert(typeof(a.onclick) == "function"); Is there a better method of detecting event support in Firefox?

    Read the article

  • Javascript onclick() event bubbling - working or not?

    - by user1071914
    I have a table in which the table row tag is decorated with an onclick() handler. If the row is clicked anywhere, it will load another page. In one of the elements on the row, is an anchor tag which also leads to another page. The desired behavior is that if they click on the link, "delete.html" is loaded. If they click anywhere else in the row, "edit.html" is loaded. The problem is that sometimes (according to users) both the link and the onclick() are fired at once, leading to a problem in the back end code. They swear they are not double-clicking. I don't know enough about Javascript event bubbling, handling and whatever to even know where to start with this bizarre problem, so I'm asking for help. Here's a fragment of the rendered page, showing the row with the embedded link and associated script tag. Any suggestions are welcomed: <tr id="tableRow_3339_0" class="odd"> <td class="l"></td> <td>PENDING</td> <td>Yabba Dabba Doo</td> <td>Fred Flintstone</td> <td> <a href="/delete.html?requestId=3339"> <div class="deleteButtonIcon"></div> </a> </td> <td class="r"></td> </tr> <script type="text/javascript">document.getElementById("tableRow_3339_0").onclick = function(event) { window.location = '//edit.html?requestId=3339'; };</script>

    Read the article

  • Switching Javascript Function states

    - by webzide
    Dear experts, I would like to implement a API of Javascript that sort of resemble a light switch. For instance, there are two buttons on the actual HTML page act as the UI. Both of the buttons have event handlers that invokes a different function. Each function have codes that act like a state, for instance. button1.onclick=function (){ $("div").click( //code effects 2 ) } button2.onclick=function (){ $("div").click( //Code effects 2 ) } I the code works fine on the surface but the 2 state functions overlap. the effects is going to take place for the rest of the way until the next reload of the document. Basically what I want to achieve is that when 1 button is clicked, it will switch "OFF" the state of function invoked by the other button and vice versa. Thus, the effects achieved are unique are not overlapped. Is there anyway to achieve this or could any experts point me to the right direction. Thanks in advance.

    Read the article

  • Why bubling not working

    - by slier
    I just want to understand how capturing and bubbling work. Unfortunately this code just work in IE, and not working in firefox. When i click on div3, it just stop there.it not bubling up toward body element. Can somebody enlighten me. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> <title>Untitled 1</title> <script type="text/javascript"> var addEvent = function(elem, event, func, capture){ if(typeof(window.event) != 'undefined'){ elem.attachEvent('on' + event, func); } else{ elem.addEventListener(event, func, capture); } } var bodyFunc = function(){ alert('In element body') } var div1Func = function(){ alert('In element div1') } var div2Func = function(){ alert('In element div2') } var div3Func = function(){ alert('In element div3') } var init = function(){ addEvent(document.getElementsByTagName('body')[0], 'click', bodyFunc, true); addEvent(document.getElementById('div1'), 'click', div1Func, true); addEvent(document.getElementById('div2'), 'click', div2Func, true); addEvent(document.getElementById('div3'), 'click', div3Func, true); } addEvent(window, 'load', init, false) </script> </head> <body> <h1>Using the Modern Event Model</h1> <div id="div1" style="border:1px solid #000000;padding:10pt;background:cornsilk"> <p>This is div 1</p> <div id="div2" style="border:1px solid #000000;padding:10pt;background:gray"> <p>This is div 2</p> <div id="div3" style="border:1px solid #000000;padding:10pt; background:lightBlue"> <p>This is div 3</p> </div> </div> </div> </body> </html>

    Read the article

  • Why is FBJS dropping my 'onclick' attribute from this input element?

    - by Chris Barnhill
    When I include an 'onClick' attribute in setInnerXTHML() like this: var innerHtml = '<span>Build Track: Select a city where track building should begin'+ '<div id="action-end">'+ '<form>'+ '<input type="button" value="End Track Building" id="next-phase" onClick="moveTrainAuto();" />'+ '</form>'+ '</div></span>'; actionPrompt.setInnerXHTML(innerHtml); var btn = document.getElementById('next-phase'); btn.addEventListener('click', 'moveTrainAuto'); The 'onClick' gets dropped. I know this from inspecting the element with Firebug. This is what it reveals: <input id="app148184604666_next-phase" type="button" value="End Track Building"/> Here is the function called for onClick: function moveTrainAuto(evt) { debugger; ajax = new Ajax(); ajax.responseType = Ajax.JSON; ajax.ondone = function(data) { debugger; if(data.code == 'UNLOAD_CARGO') { unloadCargo(); } else if (data.code == 'MOVE_TRAIN_AUTO') { moveTrainAuto(); } else if (data.code == 'TURN_END') { turnEnd(); } else { /* handle error */ } } ajax.post(baseURL + '/turn/move-trains-auto'); } As you can see, I've tried both 'onClick' and 'addEventListener'. Neither works. Any ideas?

    Read the article

  • Capture and handling the tab/Textchanged event in a textbox in asp.net MVC

    - by Icerman
    I have the following code th handle a user name validation on the server side. But the event seems not firing since break points in js or C# code didn't hit. Can anyone point out where I did wrong? Here is the user control which has a user name textbox: <%: Html.TextBox("UserName", Model.Username, new { maxlength = "40", size = "20", tabindex = "1", @onchange = "CheckAvailability()" })% CheckAvailability() is defined in the User.Validation.js and included in the above user control: $(document).ready(function () { function CheckAvailability() { $.post("/Home/Survey/CheckAvailability", { Username: $("#UserName").val() }, function (data) { var myObject = eval('(' + data + ')'); var newid = myObject; if (newid == 0) { $("#usernamelookupresult").html("<font color='green'>Available :-D</font>") } else { $("#usernamelookupresult").html("<font color='red'>Taken :-(</font>") } }); } }); Here is the survey controller function which will have server side validation: [HttpPost] public ActionResult CheckAvailability(string Username) { int Taken = 0; // This is where you add your database lookup if (Username == "abc") { Taken = 1; } return Json(Taken); }

    Read the article

  • MooTools event listener disappears after element.innerHTML is changed

    - by acoder
    Hi everyone, I am trying to achieve this task using MooTools. Description: I attached an event listener to "myButton" link. A click on this link initiates an AJAX request and updates "myDiv" content based on the response text. During this request a POST variable is being sent to "button.php", but it's not used at the moment.. (i wish to use it later) OK, as a result, "myDiv" gets exactly the same link with the same ID (myButton) + a random number, so that we could see that each click generates a new number. The problem: After the first click on "myButton", "myDiv" updates correctly, showing a random number. When I click "myButton" for the second time (this time in newly updated div), the div does not refresh anymore. Please note that I need "myButton" to be inside "myDiv", and "myDiv" must be updated (refreshed) after each click without having to refresh the entire page. Can somebody show me how to achieve this task based on this simplified code example? index.html <html> <head> <script type="text/javascript" src="mootools-1.2.4-core-nc.js"></script> <script> window.addEvent('domready', function() { $('myButton').addEvent('click', function(e) { e.stop(); var myRequest = new Request({ method: 'post', url: 'button.php', data: { action : 'test' }, onRequest: function() { $('myDiv').innerHTML = '<img src="images/loading.gif" />'; }, onComplete: function(response) { $('myDiv').innerHTML = response; } }); myRequest.send(); $('myButton').removeEvent('click'); }); }); </script> </head> <body> <div id="myDiv"> <a id="myButton" href="#">Button</a> </div> </body> </html> button.php <a id="myButton" href="#">Button</a> clicked <?php echo rand(1,100); ?>

    Read the article

  • adding new Input to jquery validationEngine form?

    - by Hailwood
    I have some fairly complex ajax logic etc going on in the onValidationComplete function for a form with jQuery Validation Engine. This is working perfect, but one thing is bothering me. in the form I have the ability to dynamically add inputs (add new row button). so my code structure wise looks like: var form = $('#myForm'); form.validationEngine('attach', {onValidationComplete:validationComplete}); $('#newInput').on('click', function(){ form.append('<input />'); form.validationEngine('detach'); form.validationEngine('attach', {onValidationComplete:validationComplete}); }); function validationComplete(form, status){/*all my logic here*/} What I don't like about it is that every time I add a new input I have to detach and then re-attach the validationEngine. Is there any way to just tell it to add the new input to it's list of inputs to validate?

    Read the article

  • Target on click

    - by 2x2p1p
    Hi guys. Look this code: <div> <a href = "#"><span>Click me MAN !</span></a> </div> <script type = "text/javascript"> window.onload = function () { document.body.addEventListener ("click", function (event) { var target = event.target; alert ("Returns \"" + target.nodeName + "\". Just want \"" + target.parentNode.nodeName + "\"") }, false); } </script> You can see the element "span" inside a "link", when the "link" is clicked the current target is the same "span". How can the "event.target" return "link" instead of "span". Thanks and no, I don't want to use "parentNode".

    Read the article

  • Why is my jQuery event not being triggered when the button is clicked?

    - by Ankur
    I am trying to call the .ajax() method when a button with id=go is clicked. This button is displayed when another jQuery event is triggered, namely that a button with a class called predicate is clicked. The button with id=go is displayed without any problems but on clicking it, there is no call to the alert() or getResults() method which are supposed to occur. Howver if I hard code the button with id=go into the page and don't have it generated by jQuery then the thing works fine. Why does the generated code cause a problem. $(document).ready( function() { $(".predicate").click( function() { makeQuery(this.id); //alert(this.id); }); $(".object").click( function() { //alert(this.id); }); var variables = 0; var queryString = ""; var noOfResults; var formValues=""; var goBegin = ""; var goEnd = "<br/><input name='go' id='go' type='button' value='go'/>"; function makeQuery(value) { queryString = queryString + "val" + variables + "=" + value + "&"; formValues=formValues+"<input type='hidden' name='val"+variables+"' value='"+value+"' />"; variables = variables + 1; $("#resultCount").html(goBegin+formValues+queryString+goEnd); } function getResults(){ $.ajax( { type : "GET", url : "ObjectCount", data : queryString + "count=" + variables, success : function(results) { noOfResults = results; $("#resultCount").html(results - 1 + " results"); } }); } $("#go").click( function() { alert("We have been alerted"); getResults(); }); });

    Read the article

  • How to get notification when window closes in Firefox extension?

    - by Yashwant Kumar Sahu
    Hello experts I am making toolbar in Mozilla Firefox. On the click of a button on my toolbar, I am opening a new window which navigates to my HTML Page created by me. On this HTML Page on the click of a button I am doing some work and closing the window. That's all done, now I need my original or parent window's toolbar to get notified when this window is closed. I guess adding event listeners won't work as its all done in new window. Please suggest. Any help is apprectiated

    Read the article

  • How do I pass the value of the previous form element into an "onchange" javascript function?

    - by Jen
    Hello, I want to make some UI improvements to a page I am developing. Specifically, I need to add another drop down menu to allow the user to filter results. This is my current code: HTML file: <select name="test_id" onchange="showGrid(this.name, this.value, 'gettestgrid')"> <option selected>Select a test--></option> <option value=1>Test 1</option> <option value=2>Test 2</option> <option value=3>Test 3</option> </select> This is pseudo code for what I want to happen: <select name="test_id"> <option selected>Select a test--></option> <option value=1>Test 1</option> <option value=2>Test 2</option> <option value=3>Test 3</option> </select> <select name="statistics" onchange="showGrid(PREVIOUS.name, PREVIOUS.VALUE, THIS.value)"> <option selected>Select a data display --></option> <option value='gettestgrid'>Show averages by student</option> <option value='gethomeroomgrid'>Show averages by homeroom</option> <option value='getschoolgrid'>Show averages by school</option> </select> How do I access the previous field's name and value? Any help much appreciated, thx! Also, JS function for reference: function showGrid(name, value, phpfile) { xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } var url=phpfile+".php"; url=url+"?"+name+"="+value; url=url+"&sid="+Math.random(); xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); }

    Read the article

  • Self-updating collection concurrency issues

    - by DEHAAS
    I am trying to build a self-updating collection. Each item in the collection has a position (x,y). When the position is changed, an event is fired, and the collection will relocate the item. Internally the collection is using a “jagged dictionary”. The outer dictionary uses the x-coordinate a key, while the nested dictionary uses the y-coordinate a key. The nested dictionary then has a list of items as value. The collection also maintains a dictionary to store the items position as stored in the nested dictionaries – item to stored location lookup. I am having some trouble making the collection thread safe, which I really need. Source code for the collection: public class PositionCollection<TItem, TCoordinate> : ICollection<TItem> where TItem : IPositionable<TCoordinate> where TCoordinate : struct, IConvertible { private readonly object itemsLock = new object(); private readonly Dictionary<TCoordinate, Dictionary<TCoordinate, List<TItem>>> items; private readonly Dictionary<TItem, Vector<TCoordinate>> storedPositionLookup; public PositionCollection() { this.items = new Dictionary<TCoordinate, Dictionary<TCoordinate, List<TItem>>>(); this.storedPositionLookup = new Dictionary<TItem, Vector<TCoordinate>>(); } public void Add(TItem item) { if (item.Position == null) { throw new ArgumentException("Item must have a valid position."); } lock (this.itemsLock) { if (!this.items.ContainsKey(item.Position.X)) { this.items.Add(item.Position.X, new Dictionary<TCoordinate, List<TItem>>()); } Dictionary<TCoordinate, List<TItem>> xRow = this.items[item.Position.X]; if (!xRow.ContainsKey(item.Position.Y)) { xRow.Add(item.Position.Y, new List<TItem>()); } xRow[item.Position.Y].Add(item); if (this.storedPositionLookup.ContainsKey(item)) { this.storedPositionLookup[item] = new Vector<TCoordinate>(item.Position); } else { this.storedPositionLookup.Add(item, new Vector<TCoordinate>(item.Position)); // Store a copy of the original position } item.Position.PropertyChanged += (object sender, PropertyChangedEventArgs eventArgs) => this.UpdatePosition(item, eventArgs.PropertyName); } } private void UpdatePosition(TItem item, string propertyName) { lock (this.itemsLock) { Vector<TCoordinate> storedPosition = this.storedPositionLookup[item]; this.RemoveAt(storedPosition, item); this.storedPositionLookup.Remove(item); } } } I have written a simple unit test to check for concurrency issues: [TestMethod] public void TestThreadedPositionChange() { PositionCollection<Crate, int> collection = new PositionCollection<Crate, int>(); Crate crate = new Crate(new Vector<int>(5, 5)); collection.Add(crate); Parallel.For(0, 100, new Action<int>((i) => crate.Position.X += 1)); Crate same = collection[105, 5].First(); Assert.AreEqual(crate, same); } The actual stored position varies every time I run the test. I appreciate any feedback you may have.

    Read the article

  • How can i check if key is pressed during click event with jquery?

    - by daniel smith
    Hi, I would like to catch a click event with jquery and be able to tell if a key was pressed at the same time so i can fork within the callback function based on the keypress. for example: $("button").click(function() { if([KEYPRESSED WHILE CLICKED]) { do something... } else { do something different... } }); Does anyone know if this is possible at all or how it can be done if it is possible?

    Read the article

  • jQuery click event not working when mouse moves from one div to another with button held down

    - by Acorn
    I've made a page that uses jQuery to allow you to place <div>s on the page based on your mouse coordinates when you click. The page And here's the javascript: $('document').ready(function() { $("#canvas").click(function(e){ var x = e.pageX - this.offsetLeft; var y = e.pageY - this.offsetTop; $(document.createElement('div')).css({'left':x + 'px', 'top':y + 'px'}).addClass('tile').appendTo('#canvas'); }); }); I've found that if you mousedown in the div#canvas and mouseup with your pointer over a placed <div> (or vice versa) then a new <div> doesn't get placed. Why is this?

    Read the article

  • move carat to the end of a text input field AND make the end visible

    - by user322384
    I'm going insane. I have an autosuggest box where users choose a suggestion. On the next suggestion selection the value of the text input box exceeds its size. I can move the carat to the end of the input field crossbrowser, no problem. But on Chrome and Safari I cannot SEE the carat at the end. The end of the text is not visible. Is there a way to move the carat to the end of a text input field AND have the end of the field visible so that the user is not confused about where the input carat went? what I got so far: <html> <head><title>Field update test</title></head> <body> <form action="#" method="POST" name="testform"> <p>After a field is updated the carat should be at the end of the text field AND the end of the text should be visible</p> <input type="text" name="testbox" value="" size="40"> <p><a href="javascript:void(0);" onclick="add_more_text();">add more text</a></p> </form> <script type="text/javascript"> <!-- var count = 0; function add_more_text() { var textfield = document.testform.elements['testbox']; textfield.blur(); textfield.focus(); if (count == 0) textfield.value = ''; // clear old count++; textfield.value = (count ? textfield.value : '') + ", " + count + ": This is some sample text"; // move to the carat to the end of the field if (textfield.setSelectionRange) { textfield.setSelectionRange(textfield.value.length, textfield.value.length); } else if (textfield.createTextRange) { var range = textfield.createTextRange(); range.collapse(true); range.moveEnd('character', textfield.value.length); range.moveStart('character', textfield.value.length); range.select(); } // force carat visibility for some browsers if (document.createEvent) { // Trigger a space keypress. var e = document.createEvent('KeyboardEvent'); if (typeof(e.initKeyEvent) != 'undefined') { e.initKeyEvent('keypress', true, true, null, false, false, false, false, 0, 32); } else { e.initKeyboardEvent('keypress', true, true, null, false, false, false, false, 0, 32); } textfield.dispatchEvent(e); // Trigger a backspace keypress. e = document.createEvent('KeyboardEvent'); if (typeof(e.initKeyEvent) != 'undefined') { e.initKeyEvent('keypress', true, true, null, false, false, false, false, 8, 0); } else { e.initKeyboardEvent('keypress', true, true, null, false, false, false, false, 8, 0); } textfield.dispatchEvent(e); } } // --> </script> </body> </html> Thanks

    Read the article

  • what is the event to handle row scrolling in EXTJS Gridpanel?

    - by user1480705
    I am displaying data in a GridPanel. My requirement is to hide some menu items based on the row selections. I have this perfectly working when a user clicks or rightclicks - i am handling the event for rowclick and rowcontextmenu respecitvely. But i am facing issue to locate the event - If the user first clicks on the row and them use up and down arrows to move on to other rows. Thanks in Advance

    Read the article

  • jQuery event trigger - cancelable event

    - by Dismissile
    I have created a jquery plugin which is triggering an event: $.fn.myplugin = function(options) { this.on("foo.myplugin", options.foo); this.on("bar.myplugin", options.bar); }; I want to check if foo has been canceled by a user and prevent bar from being triggered: // trigger foo this.trigger("foo.myplugin"); // how do I check if foo was canceled if( !fooCanceled ) { this.trigger("bar.myplugin"); } How can I check if foo was canceled to prevent bar from being triggered? jQuery UI does something similar to this, but it did not work when I tried: if (this._trigger("search", event) === false) { return; } I tried something similar to this: if( this.trigger("foo.myplugin") === false ) { return; } this.trigger("bar.myplugin"); But bar was still being triggered.

    Read the article

  • how to set a polyline on google maps every time when i click twice(make two markers) on maps,

    - by zjm1126
    this is my code : thanks <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile10.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=5.0,user-scalable=yes"> </head> <body onload="initialize()" onunload="GUnload()"> <style type="text/css"> </style> <div id="map_canvas" style="width: 500px; height: 300px;float:left;"></div> <script src="jquery-1.4.2.js" type="text/javascript"></script> <script src="jquery-ui-1.8rc3.custom.min.js" type="text/javascript"></script> <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA-7cuV3vqp7w6zUNiN_F4uBRi_j0U6kJrkFvY4-OX2XYmEAa76BSNz0ifabgugotzJgrxyodPDmheRA&sensor=false"type="text/javascript"></script> <script type="text/javascript"> //********** function initialize() { if (GBrowserIsCompatible()){ //var map = new GMap2(document.getElementById("map_canvas")); //map.setCenter(new GLatLng(39.9493, 116.3975), 13); var map = new GMap2(document.getElementById("map_canvas")); var center=new GLatLng(39.917,116.397); map.setCenter(center, 13); map.addOverlay(new GMarker(new GLatLng(39.917,116.397))); map.enableDrawing() //GEvent.addListener(map, "mouseover", function() { //alert("???????"); //}); var one; aFn=function(y_scale,x_scale){ //************ //function p(){ var bounds = map.getBounds(); var southWest = bounds.getSouthWest(); var northEast = bounds.getNorthEast(); var lngSpan = northEast.lng() - southWest.lng(); var latSpan = northEast.lat() - southWest.lat(); var point = new GLatLng(southWest.lat() + latSpan * (1-y_scale), southWest.lng() + lngSpan * x_scale); if(!one){ map.addOverlay(new GMarker(point)); one=point; }else{ var polyline = new GPolyline([one,point], "#ff0000", 5); map.addOverlay(polyline); one=0; } } //********** //************* } } </script> </body> </html>

    Read the article

  • Executing a jquery effect on demand. Is it possible?

    - by Chocol8
    I was looking the Highlight effect of Jquery's. That effect is really the one i would like to add in my webpage. By looking at the the source code, i noticed that the effect will be reproduced on user's click of the div. $("div").click(function () { $(this).effect("highlight", {}, 3000); }); In my webpage i have an ImageButton <asp:ImageButton ID="btnFavorite" runat="server" ImageUrl="~/Images/Favorite.png"/> I would love to perform the highlight effect to the div, when the user clicks on the image button. Is it possible? UPDATE: If it is possible, could i use something like "OnClientClick=" of the ImageButton, since the imagebutton controls are added dynamically to the webpage?

    Read the article

< Previous Page | 99 100 101 102 103 104 105 106 107 108 109 110  | Next Page >