Search Results

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

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

  • Removing DOM event handlers in long-running browser session

    - by Chris Beck
    I have a browser interface with a ul#contacts list on the left and div#contact property panel (email, phone) on the right. Click a contact in the list and my app makes an XHR request to get the contact property HTML fragment and update div#contact.innerHTML. Each contact fragment has an "Edit Contact" link. With JS, I progressively upgrade that link with an event listener that performs an XHR request to replace the static property panel with an in-place edit form. This can happen many times during a single browser session. How should I clean up my "Edit Contact" event listener? Do I need to remove it manually before the form overwrites the property panel? Or is the event listener cleaned up automatically when the contents of div#contact (and the node that I'm listening on) is overwritten? FWIW, I still consider IE6 to be part of my target market.

    Read the article

  • Javascript get anchor href on click

    - by Infinity
    Hello guys! How can I get the href of an anchor when I click on it using javascript? I did the following: document.onClick = myFunc(); function myFunc() { } But how to extend the function to respond only to clicks on anchors and get the href?

    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

  • jQuery - How can I temporarily disable the onclick event listener after the event has been fired?

    - by aldux
    How can I temporarily disable the onclick event listener, (jQuery preferred), after the event has been fired? Example: After the user clicks on the button and fires this function below, I want to disabled the onclick listener, therefore not firing the same command to my django view. $(".btnRemove").click(function(){ $(this).attr("src", "/url/to/ajax-loader.gif"); $.ajax({ type: "GET", url: "/url/to/django/view/to/remove/item/" + this.id, dataType: "json", success: function(returned_data){ $.each(returned_data, function(i, item){ // do stuff }); } }); Thanks a lot, Aldo

    Read the article

  • Doing some stuff right before the user exits the page

    - by Mike
    I have seen some questions here regarding what I want to achieve and have based what I have so far on those answer. But there is a slight misbehavior that is still irritating me. What I have is sort of a recovery feature. Whenever you are typing text, the client sends a sync request to the server every 45 seconds. It does 2 things. First, it extends the lease the client has on the record (only one person may edit at one time) for another 60 seconds. Second, it sends the text typed so far to the server in case the server crashes, internet connection fails, etc. In that case, the next time the user enters our application, the user is notified that something has gone wrong and that some text was recovered. Think of Microsoft or OpenOffice recovery whenever they crash! Of course, if the user leaves the page willingly, the user does not need to be notified and as a result, the recovery is deleted. I do that final request via a beforeunload event. Everything went fine until I was asked to make a final adjustment... The same behavior you have here at stack overflow when you exit the editor... a confirm dialogue. This works so far, BUT, the confirm dialogue is shown twice. Here is the code. The event if (local.sync.autosave_textelement) { window.onbeforeunload = exitConfirm; } The function function exitConfirm() { var local = Core; if (confirm('blub?')) { local.sync.autosave_destroy = true; sync(false); return true; } else { return false; } }; Some problem irrelevant clarifications: Core is a global Object that contains a lot of variables that are used everywhere. sync makes an ajax request. The values are based on the values that the Core.sync object contains. The parameter determines if the call should be async (default) or sync. Edit 1 I did try to separate both things (recovery deletion and user confirmation that is) into beforeunload and unload. The problem there was that unload is a bit too late. The user gets informed that there is a recovery even though it is scheduled to be deleted. If you refresh the page 1 second later, the dialogue disappears as the file was deleted by then.

    Read the article

  • Multiple Input From Keyboard C# WPF

    - by Alex
    I am writing a Tetris clone in WPF. If I hold down the right arrow key, the current piece shifts right. For playability, I want to allow the user to press another key (i.e. F-key) and rotate the moving piece without having to let go of the right arrow key first. Currently when I do this, the piece stops shifting. My first basic attempt at this was hooking into Window_PreviewKeyDown(object sender, KeyEventArgs e) and then sending a message to the controller layer. How do I structure my input-listening code to allow this? My current code Here

    Read the article

  • How to capture a click on a link on a temporary layer that is hidden when the focus changes

    - by hstoerr
    We have a layer that appears when a certain text input has the focus and that should dissappear when the input loses the focus. I tried to do it like this: <input type="text" onblur="document.getElementById('hideme').style.display='none'" /> <div id="hideme">Textextext <a href="http://disney.com/">disney</a> text</div> My problem is: when the user clicks on the link link, the browser does not follow this link. It seems the layer disappears before the browser checks where the click goes. What can I do here? One idea would be to watch whether the mouse enters the hideme div and not to close it when the mouse cursor is in there, but this seems way to complicated. Do you have a better idea? By the way: you can try it out very easy by pasting this into the Tryit Editor of w3schools. :-)

    Read the article

  • addEventListener pass caller as argument

    - by Ryan
    Hi, I have the following code. And my problem is that when clicking, the event is firing but the argument passed is not the correct one. It is passing the last dynamically created row i.e. dataStructure.length value. Anyone knows a solution how to get around this? var table = document.getElementById('output'); for(i =0; i<dataStructure.length; i++){ var row = document.createElement('tr'); row.setAttribute('id', i); var url = dataStructure[i].url; if(document.addEventListener) row.addEventListener('click', function(){handleRowClick(i);}, false); var obj = dataStructure[i]; var cellCount = 0; for(field in obj){ var cell = document.createElement('td'); cell.setAttribute('id', cellCount++); //cell.addEventListener('click', function(){window.open(dataStructureObj.links[i].url);}, false); cell.innerHTML = obj[field]; row.appendChild(cell); } cellCount = 0; table.appendChild(row); } } function handleRowClick(rowClicked){ var rowHTML = rowClicked.innerHTML; var cells = rowHTML.getElementsByTagName('td'); for(cell in cells) { alert(cell.value); } window.open(cells[1].innerHTML); }

    Read the article

  • Remote Ajax Call in jQuery .click() function doesn't finish before going to next page.

    - by Clint
    I need to send click information on my website to a third party server using ajax (json). I am using jquery and I added the click event to certain links. In the click event I am making a json request to a remote server with the location of the click (heat map) and some other information. The problem is that the ajax function doesn't fire in time before the default link action happens. Setting async to false doesn't seem to work on remote ajax calls. I have tried preventDefault(), but then I don't know how to run the default action after the successful ajax call. Here is what I want to do: $('a').click(submit_click); function submit_click(e,fireAjax){ e.preventDefault(); cd_$.ajax({ url: jsonUrl, //remote server dataType: 'json', data: jsonData, async: false, success: function(reply){ //Run the default action here if I have to disable the default action }, }); } Any suggestions?

    Read the article

  • onMouseOver, hyperlink and rel...help me :(

    - by bahamut100
    Hi, Currently, I have a carrousel on javascript which works when we click on hyperlink, like this : <div id="direction1"> <p> <a href="javascript:" class="carousel-control" rel="next"><img class="fleche_suiv" src="/project/images/next.png" alt="Suivant" title="Suivant" /> </a> </p> </div> I would like execute this evenment with a onMouseOver too. So I try this, but it doesn't work : <div id="direction1"> <p onMouseOver="this.getElementsByTagName('a').click()"> <a href="javascript:" class="carousel-control" rel="next"><img class="fleche_suiv" src="/project/images/next.png" alt="Suivant" title="Suivant" /> </a> </p> </div> How to fix it ???

    Read the article

  • Validation of textarea

    - by Hulk
    How to validate a textarea in a form.i.e, it should not be empty or have any new lines and if so raise an alert <script> function val() { //ifnewline found or blank raise an alert } </script> <form> <textarea name = "pt_text" rows = "8" cols = "8" class = "input" WRAP ></textarea> <input type=""button" onclick="val();" </form> Thanks

    Read the article

  • Output something other than True or False

    - by David
    Newb to JS. Trying to determain how to to output something other than Question 1 is True and False. If I understand this correctly, the output is the expression of the flag True or False. Trying to change to say Correct and Incorrect. Also trying to express a percentage of correct instead of the for example: Your total score is 10/100 $(function(){ var jQuiz = { answers: { q1: 'd', q2: 'd', }, questionLenght: 2, checkAnswers: function() { var arr = this.answers; var ans = this.userAnswers; var resultArr = [] for (var p in ans) { var x = parseInt(p) + 1; var key = 'q' + x; var flag = false; if (ans[p] == 'q' + x + '-' + arr[key]) { flag = true; g } else { flag = false; } resultArr.push(flag); } return resultArr; }, init: function(){ $("[class=btnNext]").click(function(){ if ($('input[type=radio]:checked:visible').length == 0) { return incorrect ; } $(this).parents('.questionContainer').fadeOut(500, function(){ $(this).next().fadeIn(500); }); var el = $('#progress'); el.width(el.width() + 11 + 'px'); }); $('.btnPrev').click(function(){ $(this).parents('.questionContainer').fadeOut(500, function(){ $(this).prev().fadeIn(500) }); var el = $('#progress'); el.width(el.width() - 11 + 'px'); }) $("[class=btnShowResult]").click(function(){ var arr = $('input[type=radio]:checked'); var ans = jQuiz.userAnswers = []; for (var i = 0, ii = arr.length; i < ii; i++) { ans.push(arr[i].getAttribute('id')) } }) $('.btnShowResult').click(function(){ $('#progress').width(260); $('#progressKeeper').hide(); var results = jQuiz.checkAnswers(); var resultSet = ''; var trueCount = 0; for (var i = 0, ii = results.length; i < ii; i++){ if (results[i] == true) trueCount++; resultSet += '<div> Question ' + (i + 1) + ' is ' + results[i] + '</div>' } resultSet += '<div class="totalScore">Your total score is ' + trueCount * 4 + ' / 100</div>' $('#resultKeeper').html(resultSet).show(); }) } }; jQuiz.init(); })

    Read the article

  • How to set the value of a wx.combobox by posting an event

    - by Adam Fraser
    The code below demonstrates the problem I am running into. I am creating a wx.ComboBox and trying to mimic it's functionality for testing purposes by posting a wxEVT_COMMAND_COMBOBOX_SELECTED event... this event strangely works fine for wx.Choice, but it doesn't do anything to the ComboBox. There doesn't appear to be a different event that I can post to the combobox, but maybe I'm missing something. I'm running this code on Python 2.5 on a Mac OSX 10.5.8 import wx app = wx.PySimpleApp() def on_btn(evt): event = wx.CommandEvent(wx.wxEVT_COMMAND_COMBOBOX_SELECTED,combobox.Id) event.SetEventObject(combobox) event.SetInt(1) event.SetString('bar') combobox.Command(event) app.ProcessPendingEvents() frame = wx.Frame(None) panel = wx.Panel(frame, -1) # This doesn't work combobox = wx.ComboBox(panel, -1, choices=['foo','bar']) # This works #combobox = wx.Choice(panel, -1, choices=['foo','bar']) combobox.SetSelection(0) btn = wx.Button(panel, -1, 'asdf') btn.Bind(wx.EVT_BUTTON, on_btn) sz = wx.BoxSizer() sz.Add(combobox) sz.Add(btn) panel.SetSizer(sz) frame.Show() app.MainLoop()

    Read the article

  • Javascript parent page redirection from iframe.

    - by Danil
    Hello to all. I need to implement parent page redirection from iframe. I know that it is impossible to do in different domains due to browsers security. However I found that links have target attribute and tried to use it in the following way: <a href="http://google.com" target="_top" id="testParentRedirect">someLink</a> It works fine if I click this link manually, but I couldn't find cross-browser solution to simulate it using javascript. document.getElementById('testParentRedirect').click(); This works fine in IE, however Firefox and Safary don't know click function :). I tried to work with jquery, but for some reason they don't simulate click event for links. (see following post) I couldn't find any appropriate solution on stackoverflow. Maybe someone could help me in it. I will appreciate it. :)

    Read the article

  • JavaScript: Very strange behavior with assigning methods in a loop

    - by Andrey
    Consider this code below: <a href="javascript:void(-1)" id="a1">a1</a> <a href="javascript:void(-1)" id="a2">a2</a> <script type="text/javascript"> var buttons = [] buttons.push("a1") buttons.push("a2") var actions = [] for (var i in buttons) { actions[buttons[i]] = function() { alert(i) } } var elements = document.getElementsByTagName("a") for (var k = 0; k < elements.length; k++) { elements[k].onclick = actions[elements[k].id] } </script> Basically, it shows two anchors, a1 and a2, and I expect to see "1" and "2" popping up in an alert when clicking on corresponding anchor. It doesn't happen, I get "2" when clicking on either. After spending an hour meditating on the code, I decided that it probably happens because dynamic onclick methods for both anchors keep the last value of "i". So I change that loop to for (var i in buttons) { var local_i = i.toString() actions[buttons[i]] = function() { alert(local_i) } } hoping that each dynamic function will get its own copy of "i" with immediate value. But after this change I get "1" popping up when I click on either link. What am I doing wrong? It's a huge show stopper for me.

    Read the article

  • How can I retrieve the value of a PASTE (copy-pasta) event in a GWT TextBox?

    - by dominicbri7
    Hello fellow SO members, I want to prevent the user from copy-pasting values in my TextBox IF AND ONLY IF the values do not respect a certain condition. For instance, I created a DigitsOnlyTextBox which will be used for phone numbers. I already made it so only Character.isDigit characters can be typed into the box, and the user cannot copy-paste values into it, using : this.sinkEvents(Event.ONPASTE); and public void onBrowserEvent(Event event) { super.onBrowserEvent(event); // Permet d'empêcher le copier-coller, donc d'entrer des caractères non-numériques if (event.getTypeInt() == Event.ONPASTE) { event.stopPropagation(); event.preventDefault(); } } But I'd like to verify if the copy-pasted String is "digits only" and if so, let the event happen (therefore the text added). tl;dr : see title Thank you for your time. Sincerely.

    Read the article

  • How to save event handlers, when we set new html for element?

    - by Kai
    I have simple html markup: <div id="cont">Some text here <div class="wrap" style="border: 1px solid black;display: inline;"> block element here </div> and another text</div> And jQuery code: $(function(){ $(".wrap").click(function(){ $("#cont").html($("#cont").html().replace(/text/g, "letter")); alert("Click!"); }); $("#d1").click(function(){ alert("#d1 clicked!"); }); }); I expect that click event will be fire any time you clicked by the #d1 div, but when we clicked by .wrap it neve fire again. I understand why it has such behavior, but how to solve it? In my code I can't set click event for #d1 after $("#cont").html($("#cont").html().replace(/text/g, "letter")) because I don't now at execution time if event was set. You can try example on JSBin

    Read the article

  • about onmouseout event.please help.

    - by lazyanno
    as follow codes: <div id="outerBox" style="border:1px solid red;width:300;height:300" onmouseout="alert('out')"> <div id="innerBox" style="border:1px solid blue;width:50;height:50">inner</div> </div> why when i move mouse on the "innerBox", it was trigger alert('out') ? i want mouse out "outerBox" trigger alert('out') only, mouse on "innerBox" don't trigger alert. hot to do this? thanks all :)

    Read the article

  • using multi-markers with multi info-windows

    - by mohsen
    I have an array of info-windows corresponding to an array of markers. Now, I have a problem, I use the below code to generate an info-window, when clicking on the marker all the markers disappear unless one, also when I click on that marker there is no info-window come out. What is the wrong with my code ? or what shall I do ? Any answer will be very appreciated, Thanks in advance. This code is inside a for loop: infoWindoArray[i][j] = new google.maps.InfoWindow({ content:"Lat: "+this.position.lat() + "\nLng: " + this.position.lng() + "\n"+ this.customInfo, }); google.maps.event.addListener(AllMarkers[i][j], 'click', (function(x) { return function() {infoWindoArray[i][j].open(map,AllMarkers[i][j]);} })(x));

    Read the article

  • How to Detect an Event Coming from the Firefox History Dropdown Box

    - by banterCZ
    How to detect an event coming from the Firefox history dropdown box? I need to distinguish between the enter key simply pressed on input field or on item from his native history dropdown box. The reason is that I would like to call custom submit button (not first one, which is default) on the enter key pressed on any input field. But right now, the enter key pressed on history dropdown box unfortunately call submit as well.

    Read the article

  • UIEvent timestamp

    - by skajam66
    When handling a UIButton touch, you are given a UIEvent object. The UIEvent object has a timestamp which the Apple documentation states as being "the time that the event was created" (UIEvent Class Reference). In the documentation on the Main Event Loop, it states that: "The application object obtains the topmost object in the event queue, converts it to an event object (UIEvent) ..." Does [UIEvent timestamp] refer to the time at which the UIEvent object is created (i.e. after processing the touch event off of the main run loop and hance not remotely real-time) or does it refer to the time that the underlying touch object was created (and hence as close as possible to representing the actual time of the user touch9?

    Read the article

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