Search Results

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

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

  • Trying to perform a series of actions on page unload, but the pages unloads too fast to finish them.

    - by user138821
    I have a series of actions I want to perform on page unload. Namely if a user is editing an input field, and they refresh or close browser or leave page, I want to save the contents of the field. The actions don't include an AJAX call, so I can't just make it synchronous. It's actually saving to local storage, but the page unloads before the storage can take place. The code is correct, if I add an alert to the actions, the delay allows the rest of the code to finish before it even displays. Any ideas? Thanks!

    Read the article

  • Progressive enhancement of anchor tags to avoid onclick="return false;"

    - by Chris Beck
    Unobtrusive JS suggests that we don't have any onclick attributes in our HTML templates. <a href="/controller/foo/1">View Foo 1</a> A most basic progressive enhancement is to convert an that anchor tag to use XHR to retrieve a DOM fragment. So, I write JS to add an event listener for a."click" then make an XHR to a.href. Alas, the browser still wants to navigate to "/controller/foo". So, I write JS to dynamically inject a.onclick = "return false;". Still unobtrusive (I guess), but now I'm paying the the cost of an extra event handler. To avoid the cost of 2 event listeners, I could shove my function call into the onclick attribute <a href="/controller/foo/1" onclick="myXHRFcn(); return false;"> But that's grodo for all sorts of reasons. To make it more interesting, I might have 100 anchor tags that I want to enhance. A better pattern is a single listener on a parent node that relies on event bubbling. That's cool, but how do I short circuit the browser from navigating to the URL without this on every anchor node? onclick="return false;" Manipulating the href is not an option. It must stay intact so the context menu options to copy or open in new page work as expected.

    Read the article

  • java Swing Listeners: components listening at each others.

    - by Pierre
    Hi all, I want to code two JList (categories and items). When I click one category it should select all the items for that category and when I click on one item it should select its categories. So both JList will have a ListSelectionListener listening at each other and changing the selection. Should I fear about some a of "loop" ? Is there a way to tell that an Event has been consumed ? how do people manage that kind of situation ? Thanks

    Read the article

  • Context Menu event with QGraphicsWidget

    - by onurozcelik
    In my application I subclass QGraphicsWidget In paint I am drawing a line with pen width 4. I reimplemented boundingRect() and shape(). But I can't catch context menu event every time I click right mouse button. What is the problem.(Pen Width ? ) //Sample code for boundingRect() and shape() QRectF boundingRect() const { qreal rectLeft = x1 < x2 ? x1 : x2; qreal rectTop = y1 < y2 ? y1 : y2; qreal rectWidth = (x1 - x2) != 0 ? abs(x1-x2) : 4; qreal rectHeight = (y1 - y2) != 0 ? abs(y1 -y2) : 4; return QRectF(rectLeft,rectTop,rectWidth,rectHeigt); } QPainterPath shape() { QPainterPath path; path.addRect(boundingRect()); return path; }

    Read the article

  • What are the caveats of the event system built on Messenger rather than on classic .NET events?

    - by voroninp
    MVVM Light and PRISM offer messenger to implement event system. the approximate interface looks like the following one: interface Messanger { void Subscribe<TMessageParam>(Action<TMessageParam> action); void Unsubscribe<TMessageParam>(Action<TMessageParam> action); void Unsubscribe<TMessageParam>(objec actionOwner); void Notify<TMessageParam>(TMessageParam param); } Now this model seems beneficial comparing to classic .net events. It works well with Dependency Injection. Actions are stored as weak references so memory leaks are avioded and unsubscribe is not a must. The only annoyance is the need to declare new TMessageParam for each specific message. But everything comes at a cost. And what I'm really worried about is that I see no shortcomings of this approach. Has anoyne the experience of some troubles with this design pattern?

    Read the article

  • C# BackgroundWorker RunWorkerCompleted Event

    - by Jim Fell
    My C# application has several background workers. Sometimes one background worker will fire off another. When the first background worker completes and the RunWorkerCompleted event is fired, on which thread will that event fire, the UI or the first background worker from which RunWorkerAsync was called? I am using Microsoft Visual C# 2008 Express Edition. Any thoughts or suggestions you may have would be appreciated. Thanks.

    Read the article

  • How to stop an event for raising

    - by Akshay
    Hi, I have Two fields, one textbox nad one Div element. I have onblur event for textbox, and onclick event for div element. when i click the div element the textbox's onblur event occurs and not the onclick event of div element. how to supress the onblur event when i click on the div element Thanks in advance

    Read the article

  • Handling download abort in PHP

    - by Aron Rotteveel
    Is it somehow possible to handle a download abort in PHP? In this specific case I am not speaking of a connection abort, but handling the event that triggers when the 'cancel' button in the browser download dialog button is clicked. Since this dialog already interprets the headers of the file that is to be download but does not actually start the download, it only seems logical there should be some way to catch this. Small (pseudo) code example to clear things up: // set some headers header('...'); // Question: what happens between the part where the headers are sent // and the actual data is being outputted to the client? IE: this is the part // where the download dialog should show up // Logical question that follows is: is there a way to detect a 'cancel'? $filename = '/some/file.txt'; $handle = fopen($filename, 'rb'); // output data to client while (!feof($handle)) { echo fread($handle, 8096); } fclose($handle);

    Read the article

  • Which is the event listener after doSave() in Symfony?

    - by fesja
    Hi, I've been looking at this event-listeners page http://www.doctrine-project.org/documentation/manual/1_1/pl/event-listeners and I'm not sure which is the listener I have to use to make a change after the doSave() method in the BaseModelForm.class.php. // PlaceForm.class.php protected function doSave ( $con = null ) { ... parent::doSave($con); .... // Only for new forms, insert place into the tree if($this->object->level == null){ $parent = Place::getPlace($this->getValue('parent'), Language::getLang()); ... $node = $this->object->getNode(); $method = ($node->isValidNode() ? 'move' : 'insert') . 'AsFirstChildOf'; $node->$method($parent); //calls $this->object->save internally } return; } What I want to do is to make a custom slug with the ancestors' name of that new place. So if I inserting "San Francisco", the slug would be "usa-california-san-francisco" public function postXXXXXX($event) { ... $event->getInvoker()->slug = $slug; } The problem is that I'm inserting a new object with no reference to its parent. After it's saved, I insert it to the tree. So I can't change the slug until then. I think a Transaction listener could work, but I'm use there is a better way I'm not seeing right now. thanks!

    Read the article

  • How to create a static delegate from main-viewcontroller?

    - by geforce
    Hi, hope someone can help me on learning some new stuff about delegates in iOS-programming. I have a "MainViewController" which is the first VC when the app starts. I´ve a kind of modelselection with different UIImageViews and after choosing one of them, i´m pushing a new VC. I want to handle the modelChoice with a delegate, so all other viewControllers can listen to that and act based on the users choice. But does that mean that i have to alloc a new instance of that "MainViewController" in every VC? Whats the solution on that? How do i create (i think its called) static delegate? Would be great to learn that.. Thanks for sharing..

    Read the article

  • Event Source Live streaming in Ruby on rails onError method

    - by kishorebjv
    I'm trying to implement basic rails4 code with eventsource API & Action controller live, Everything is fine but I'm not able to reach event listner . Controller code: class HomeController < ApplicationController include ActionController::Live def tester response.headers["Content-Type"] = "text/event-stream" 3.times do |n| response.stream.write "message: hellow world! \n\n" sleep 2 end end Js code: var evSource = new EventSource("/home/tester"); evSource.onopen = function (e) { console.log("OPEN state \n"+e.data); }; evSource.addEventListener('message',function(e){ console.log("EventListener .. code.."); },false); evSource.onerror = function (e) { console.log("Error State \n\n"+e.data); }; & When i reloading the page, My console output was "OPEN state" & then "Error State" as output.. event-listener code was not displaying . 1.When I'm curling the page, "message: Hellow world!" was displaying. 2.I changed in development.rb config.cache_classes = true config.eager_load = true 3. My browsers are chrome & firefox are latest versions, so no issues with them, Where I'm missing? suggestions please!

    Read the article

  • What jQuery is triggered when a user selects a "drop down list" option

    - by Ankur
    I want to display a different form for different selections of this drop down list: <label> <select name="type" id="type"> <option value="object" selected="selected">Object</option> <option value="number">Number</option> <option value="text">Text</option> <option value="date">Date</option> <option value="time">Time</option> <option value="geo">Geospatial</option> <option value="currency">Currency</option> </select> </label> What would be the jQuery event that is triggered when a user selects one of these options. Would the .click() event be triggered in this case as well?

    Read the article

  • Design for fastest page download

    - by mexxican
    I have a file with millions of URLs/IPs and have to write a program to download the pages really fast. The connection rate should be at least 6000/s and file download speed at least 2000 with avg. 15kb file size. The network bandwidth is 1 Gbps. My approach so far has been: Creating 600 socket threads with each having 60 sockets and using WSAEventSelect to wait for data to read. As soon as a file download is complete, add that memory address(of the downloaded file) to a pipeline( a simple vector ) and fire another request. When the total download is more than 50Mb among all socket threads, write all the files downloaded to the disk and free the memory. So far, this approach has been not very successful with the rate at which I could hit not shooting beyond 2900 connections/s and downloaded data rate even less. Can somebody suggest an alternative approach which could give me better stats. Also I am working windows server 2008 machine with 8 Gig of memory. Also, do we need to hack the kernel so as we could use more threads and memory. Currently I can create a max. of 1500 threads and memory usage not going beyond 2 gigs [ which technically should be much more as this is a 64-bit machine ]. And IOCP is out of question as I have no experience in that so far and have to fix this application today. Thanks Guys!

    Read the article

  • using JQuery on beforeprint event problem. Not answered.

    - by Cesar Lopez
    Hi all, I have the following function. <script type="text/javascript"> window.onbeforeprint = expandAll; function expandAll(){ $(".fieldset:gt(0)").slideDown("fast"); } </script> For this html <table class="sectionHeader" ><tr ><td>Heading</td></tr></table> <div style="display:none;" class="fieldset">Content</div> I have several block of content over the page, but when I do print preview or print, I can see all divs sliding down before opening the print preview or printing but on the actual print preview or print out they are all collapse. Anyone have any idea why is this? Thanks.

    Read the article

  • index seems to be out of sync for jquery .keydown and .click methods

    - by Growler
    I'd like to navigate images using both keyboard and mouse (clicking left and right arrow images). I'm using Jquery to do this, but the shared imgIndex seems to be off from the .keydown function and the .click function... Whenever .keydown function -- or ++ the imgIndex, isn't that changed index also used in the click function? So shouldn't they always be on the same index? keydown function: <script type="text/javascript"> var imgArray = [<?php echo implode(',', getImages($site)) ?>]; $(document).ready(function() { var img = document.getElementById("showimg"); img.src = imgArray[<?php echo $imgid ?>]; var imgIndex = <?php echo $imgid ?>; alert(imgIndex); $(document).keydown(function (e) { var key = e.which; var rightarrow = 39; var leftarrow = 37; var random = 82; if (key == rightarrow) { imgIndex++; if (imgIndex > imgArray.length-1) { imgIndex = 0; } img.src = imgArray[imgIndex]; } if (key == leftarrow) { if (imgIndex == 0) { imgIndex = imgArray.length; } img.src = imgArray[--imgIndex]; } }); click function: Connected to left and right clickable images $("#next").click(function() { imgIndex++; if (imgIndex > imgArray.length-1) { imgIndex = 0; } img.src = imgArray[imgIndex]; }); $("#prev").click(function() { if (imgIndex == 0) { imgIndex = imgArray.length; } img.src = imgArray[--imgIndex]; }); }); Just so you have some visibility into the getImages php function: <?php function getImages($siteParam) { include 'dbconnect.php'; if ($siteParam == 'artwork') { $table = "artwork"; } else { $table = "comics"; } $catResult = $mysqli->query("SELECT id, title, path, thumb, views, catidFK FROM $table"); $img = array(); while($row = $catResult->fetch_assoc()) { $img[] = "'" . $row['path'] . "'"; } return $img; } ?> Much appreciated! Snapshot of where the script is on "view image.php"

    Read the article

  • Detecting support for a given JavaScript event?

    - by Will
    I'm interested in using the JavaScript hashchange event to monitor changes in the URL's fragment identifier. I'm aware of Really Simple History and the jQuery plugins for this. However, I've reached the conclusion that in my particular project it's not really worth the added overhead of another JS file. What I would like to do instead is take the "progressive enhancement" route. That is, I want to test whether the hashchange event is supported by the visitor's browser, and write my code to use it if it's available, as an enhancement rather than a core feature. IE 8, Firefox 3.6, and Chrome 4.1.249 support it, and that accounts for about 20% of my site's traffic. So, uh ... is there some way to test whether a browser supports a particular event? Thanks.

    Read the article

  • button onclick not working

    - by nsw1475
    I have a javascript where I need to hide (and eventually show) some text by clicking a button. However, when I click the button, it does not call the function specified in the onclick parameter, and so nothing happens. Here is my source code: <script type="text/javascript"> $(document).ready(function(){ var tip = 1; $(".tip1").hide(); $(".tip2").hide(); switch (tip) { case 1: $(".tip1").show(); break; case 2: $(".tip2").show(); break; } function nextTip() { $(".tip1").hide(); return; } }); </script> <br/> <div id='bg_container' style='background-image: url("<?=$PICS?>trackingpage_middle.jpg")' > <img style='z-index:-1;' width='737px' src='<?=$PICS?>trackingpage_top.jpg'> <div id='main_container' > <form> <input type="button" onClick="nextTip()" value = "Next Tip" /> </form> <div class="tip1"> ... and so on.

    Read the article

  • JQuery input elements

    - by codeasp
    I need to get all input elements within a div and then attach event handlers, so that whenever values change it updates a hidden field. Children elements within the div might already contain event handlers, if so the attach should chain it. Any help is much appreciated.

    Read the article

  • how to handle signout when the browser in close in flex 3?

    - by kumar1425
    my project had audit module ,which inlcude each and every action of the user to be recoreded so when the user closes the browser the audit regarding the logout has to be stored in the database i found one solution in the net ,but it is working in my machine's IE but falied to work in the friends machines IE why? the code is: window.onbeforeunload = clean_up; function clean_up() { var flex = document.${application} || window.${application}; flex.myFlexFunction(); } i place this code in the index.template.html file in the html-template foleder under flex src and i place the below code in my main application.mxml file ExternalInterface.addCallback("myFlexFunction",btnLogout); and i defined the logout funtion if any one has solution plz answer me............. thank you..................

    Read the article

  • Automatically unsubscribe an event

    - by Cat
    Is it possible to do something like this in C#? Probably with Expressions. private void RegisterEvent(EventHandler handler, Action<EventArgs> action) { handler += action; m_toUnsubscribe.Add(handler, action); } ... in Dispose() { foreach(var pair in m_toUnsubscribe) { pair.handler -= pair.action; } }

    Read the article

  • ASP.NET button_click not firing, after browser back button

    - by the berserker
    I have a ASPX Page that contains several user controls, which are loaded dynamically after user interaction. On one of ascx I have a hidden button that is being clicked on some user actions (via button.click()), which works fine on 1st page load. But after the form is being submitted once, the other ascx is loaded. There if user clicks the back button and resubmits the 1st form (again via button.click()), button_clicked event on server does not fire again. Any thought?

    Read the article

  • How to find the width of the div or check wheather horizontal scroll apeear or not?

    - by Salil
    I want to print the page (div) if there is no horizontal scroll appear for that div. I have a div (1000px) with dynamic data which having property overflow:auto;. So, i want to print the div only if div's width is not getting crossed. to achieve this i used following method of a javascript var curr_width = parseInt(mydiv.style.width); But it gives 1000px; only althogh i can see horizontal scrollbar for the div. What should i do to achive this. Can i check wheather horizontal scrollbar is appear for the div or not. Any help is appreciated. NOTE:- i don't want to use any javascript library.

    Read the article

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