Search Results

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

Page 97/416 | < Previous Page | 93 94 95 96 97 98 99 100 101 102 103 104  | Next Page >

  • Javascript Object.Watch for all browsers?

    - by SeanW
    Hey all, I was looking for an easy way to monitor an object or variable for changes, and I found Object.Watch that's supported in Mozilla browsers, but not IE. So I started searching around to see if anyone had written some sort of equivalent. About the only thing I've found has been a jQuery plugin (http://plugins.jquery.com/files/jquery-watch.js.txt), but I'm not sure if that's the best way to go. I certainly use jQuery in most of my projects, so I'm not worried about the jQuery aspect... Anyway, the question: can someone show me a working example of that jQuery plugin? I'm having problems making it work... Or, does anyone know of any better alternatives that would work cross browser? Thanks! Update after answers: Thanks everyone for the responses! I tried out the code posted here: http://webreflection.blogspot.com/2009/01/internet-explorer-object-watch.html But I couldn't seem to make it work with IE. The code below works fine in FireFox, but does nothing in IE. In Firefox, each time watcher.status is changed, the document.write in watcher.watch is called and you can see the output on the page. In IE, that doesn't happen, but I can see that watcher.status is updating the value, because the last document.write shows the correct value (in both IE and FF). But, if the callback function isn't called, then that's kind of pointless... :) Am I missing something? var options = {'status': 'no status'}, watcher = createWatcher(options); watcher.watch("status", function(prop, oldValue, newValue) { document.write("old: " + oldValue + ", new: " + newValue + "<br>"); return newValue; }); watcher.status = 'asdf'; watcher.status = '1234'; document.write(watcher.status + "<br>");

    Read the article

  • Toggle block in jQuery

    - by user201140
    I'd like to click a header link and have the block directly underneath hide or show (with slideToggle) Thanks <div class='header'><a href='#'>Header</a></div> <div class='block'> <div class='test>Some Text</div> <div class='test>Some Text</div> <div class='test>Some Text</div> </div> <div class='header'><a href='#'>Header</a></div> <div class='block'> <div class='test>Some Text</div> <div class='test>Some Text</div> <div class='test>Some Text</div> </div> <div class='header'><a href='#'>Header</a></div> <div class='block'> <div class='test>Some Text</div> <div class='test>Some Text</div> <div class='test>Some Text</div> </div>

    Read the article

  • Why does Event intent in android not return a result?

    - by dhaval
    I am creating a event using Intent intent = new Intent(Intent.ACTION_EDIT); intent.setType("vnd.android.cursor.item/event"); And invoking the intent using startActivityForResult(intent, Constants.LINK_CALENDER); There is nothing returned to call in onActivityResult(int requestCode, int resultCode, Intent data) It always returns data=null ie., returned intent result is always null. I am trying to retrieve the "Done/Revert" state of calender event just created and some identity so that i can open the event again in future from elsewhere in code.

    Read the article

  • equality on the sender of an event

    - by Berryl
    I have an interface for a UI widget, two of which are attributes of a presenter. public IMatrixWidget NonProjectActivityMatrix { set { // validate the incoming value and set the field _nonProjectActivityMatrix = value; .... // configure & load non-project activities } public IMatrixWidget ProjectActivityMatrix { set { // validate the incoming value and set the field _projectActivityMatrix = value; .... // configure & load project activities } The widget has an event that both presenter objects subscribe to, and so there is an event handler in the presenter like so: public void OnActivityEntry(object sender, EntryChangedEventArgs e) { // calculate newTotal here .... if (ReferenceEquals(sender, _nonProjectActivityMatrix)) { _nonProjectActivityMatrix.UpdateTotalHours(feedback.ActivityTotal); } else if (ReferenceEquals(sender, _projectActivityMatrix)) { _projectActivityMatrix.UpdateTotalHours(feedback.ActivityTotal); } else { // ERROR - we should never be here } } The problem is that the ReferenceEquals on the sender fails, even though it is the implemented widget that is the sender - the same implemented widget that was set to the presenter attribute! Can anyone spot what the problem / fix is? Cheers, Berryl I didn't know you could edit nicely. Cool. Here is the event raising code: void OnGridViewNumericUpDownEditingControl_ValueChanged(object sender, EventArgs e) { // omitted to save sapce if (EntryChanged == null) return; var args = new EntryChangedEventArgs(activityID, dayID, Convert.ToDouble(amount)); EntryChanged(this, args); } Here is the debugger dump of the presenter attribute, sans namespace info: ?_nonProjectActivityMatrix {WinPresentation.Widgets.MatrixWidgetDgv} [WinPresentation.Widgets.MatrixWidgetDgv]: {WinPresentation.Widgets.MatrixWidgetDgv} Here is the debugger dump of the sender: ?sender {WinPresentation.Widgets.MatrixWidgetDgv} base {Core.GUI.Widgets.Lookup.MatrixWidgetBase<Core.GUI.Widgets.Lookup.DynamicDisplayDto>}: {WinPresentation.Widgets.MatrixWidgetDgv} _configuration: {Domain.Presentation.Timesheet.Matrix.WeeklyMatrixConfiguration} _wrappedWidget: {Win.Widgets.DataGridViewDynamicLookupWidget} AllowUserToAddRows: true ColumnCount: 11 Count: 4 EntryChanged: {Method = {Void OnActivityEntry(System.Object, Smack.ConstructionAdmin.Domain.Presentation.Timesheet.Matrix.EntryChangedEventArgs)}} SelectedCell: {DataGridViewNumericUpDownCell { ColumnIndex=3, RowIndex=3 }} SelectedCellValue: "0.00" SelectedColumn: {DataGridViewNumericUpDownColumn { Name=MONDAY, Index=3 }} SelectedItem: {'AdministrativeActivity: 130-04', , AdministrativeTime, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00} Berryl

    Read the article

  • Thread-safe queue in Javascript or jQuery

    - by at
    I have many asynchronous AJAX calls whose results will get processed. It doesn't matter what order the processing occurs, but the results need to get processed one at a time. So I'd like to simple do my AJAX calls and they all just put their results in a single queue. That queue should then get processed on a single thread. This way the results get processed one at a time as soon as possible. What's the best way to do this? I'm using jQuery, so happy to take advantage of any facilities it provides for this.

    Read the article

  • javascript: capturing load event on LINK

    - by pgn
    hello everyone, i'm trying to attach an event handler to the load event of a link tag, to execute some code after a stylesheet has loaded. new_element = document.createElement('link'); new_element.type = 'text/css'; new_element.rel = 'stylesheet'; new_element.href = 'http://domain.tld/file.css'; new_element.addEventListener('load', function() { alert('foo'); }, false); document.getElementsByTagName('head')[0].appendChild(new_element) i have tried onreadystatechange as well new_element.onreadystatechange = function() { alert('foo'); } unfortunately neither approach results in an alert being triggered.. Furthermore, new_element.onload is null after registering a handler for the 'load' event with addEventListener.. is that normal? thanks, andrew ps: i may not use any framework in solving this

    Read the article

  • is it possible to tell if DOM was modified, and which part?

    - by mkoryak
    Are there any practical ways to tell what part of the DOM was modified if you know that it will be modified? I am writing a plugin that will be running along with javascript that i did not write. an event will be triggered before DOM is modified, and one event will be triggered after the modification. It is my job to decide what was changed. is this possible, and if so what is the least horrible way to do this?

    Read the article

  • Interrupting Prototype handler, alert() vs event.stop()

    - by lxs
    Here's the test page I'm using. This version works fine, forwarding to #success: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html><head> <script type="text/javascript" src="prototype.js"></script> </head><body> <form id='form' method='POST' action='#fail'> <button id='button'>Oh my giddy aunt!</button> <script type="text/javascript"> var fn = function() { $('form').action = "#success"; $('form').submit(); } $('button').observe('mousedown', fn); </script> </form> </body></html> If I empty the handler: var fn = function() { } The form is submitted, but of course we are sent to #fail this time. With an alert in the handler: var fn = function() { alert("omg!"); } The form is not submitted. This is awfully curious. With event.stop(), which is supposed to prevent the browser taking the default action: var fn = function(event) { event.stop(); } We are sent to #fail. So alert() is more effective at preventing a submission than event.stop(). What gives? I'm using Firefox 3.6.3 and Prototype 1.6.0.3. This behaviour also appears in Prototype 1.6.1.

    Read the article

  • Extending a jquery plugins event callback

    - by Greg J
    I'm extending the functionality of a jquery plugin (foo) with another jquery plugin (bar). Essentially, the first plugin specifies an onReady(): var foo = $.foo({ onReady: function() { alert('foo'); }}); Foo is sent to bar as a parameter to bar: var bar = $.bar(foo); I want bar to be able to hook into foo's onReady event: (function($) { $.extend({ bar: function(foo) { var foo = foo; // How to do alert('bar') when foo.onready is called? } }); })(jQuery); I can override foo's onready event: foo.onready = function() { alert('bar'); } But I don't want to override it, I want to extend it so that I'll see both alerts when foo is ready. Thanks in advance!

    Read the article

  • Can I interrupt javascript code and then continue on a keystroke?

    - by Brian Ramsay
    I am porting an old game from C to Javascript. I have run into an issue with display code where I would like to have the main game code call display methods without having to worry about how those status messages are displayed. In the original code, if the message is too long, the program just waits for the player to toggle through the messages with the spacebar and then continues. This doesn't work in javascript, because while I wait for an event, all of the other program code continues. I had thought to use a callback so that further code can execute when the player hits the designated key, but I can't see how that will be viable with a lot of calls to display.update(msg) scattered throughout the code. Can I architect things differently so the event-based, asynchronous model works, or is there some other solution that would allow me to implement a more traditional event loop? Am I making sense? Example: // this is what the original code does, but obviously doesn't work in Javascript display = { update : function(msg) { // if msg is too long // wait for user input // ok, we've got input, continue } }; // this is more javascript-y... display = { update : function(msg, when_finished) { // show part of the message $(document).addEvent('keydown', function(e) { // display the rest of the message when_finished(); }); } }; // but makes for amazingly nasty game code do_something(param, function() { // in case do_something calls display I have to // provide a callback for everything afterwards // this happens next, but what if do_the_next_thing needs to call display? // I have to wait again do_the_next_thing(param, function() { // now I have to do this again, ad infinitum } }

    Read the article

  • Javascript Close Browser or goto external site function

    - by aaroninfidel
    Hello, I've been trying to figure out how I can go about creating a javascript function that will only be called when a user is accessing an external site or closing the window to the current site they're on. So far I've come up with this, any help is greatly appreciated. <script type="text/javascript"> window.onbeforeunload = confirmExit; function getAd() { var myAds = new Array(); myAds[0] = "http://localhost/link1"; myAds[1] = "http://localhost/link2"; var randomAd = Math.floor(Math.random() * myAds.length); return myAds[randomAd]; } function confirmExit(){ alert(getAd()); return false; } </script>

    Read the article

  • Simulating mouse clicks on Mac OS X does not work for some applications.

    - by Thomi
    I'm writing an application for Mac OS X 10.6 and later in C++. One part of the application needs to simulate mouse movement and mouse clicks. I do this currently by posting CGEvent objects using CGEventPost(kCGHIDEventTap, event);. This works, for the most part - I can simulate mouse movement and clicks just fine, but it seems to fail in some areas. For example: In Mozilla Firefox and Safari, I can click on all the menus, but cannot click on a link within a website. When I try, the link is highlighted, but the browser never follows the link. However, I can right-click on a link, select "open link in new tab", and everything works as expected. Solved - creating the mouse event using CGEventCreateMouseEvent(...) makes the event work within web browser. I can click on the "Dashboard" icon to brink up the dashboard, but I cannot click on the "i" button on any of the dashboard widgets. Similarly, clicking on any of the search results from the spotlight search widget doesn't work either. This inconsistency is along application boundaries. What might be the cause?

    Read the article

  • Attaching an event to an Iframe that contains more iframes

    - by Oscar Godson
    I have an editor which is in my window that contains a wrapping iframe and then 2 more iframes inside like (the HTML inside the <iframe> element is inserted via write() in JS, not hardcoded like this): <iframe class="parent"> <div class="wrapper"> <iframe class="editor"></iframe> <iframe class="previewer"></iframe> </div> </iframe> One is an editor, the other is a previewer. The first one that contains the two (we'll call this the parent) has an eventListener for mousemove attached to it, but nothing is firing. If i add a 5px border for example, the event will fire when I move my mouse on the border of the parent, but not when i hover over the middle which contains the editor or previewer (previewer is display:none while the editor is visible, and vice versa). So, the blue area in the following i can mousemove, but the rest I can't. It's most likely because of the stacking order, but how can I attach an event to fire on the entire frame? I need mousemove because on mousemove I display a menu in the bottom right. I want the same menu to display whether or not the editor or the previewer is visible.

    Read the article

  • how to stop onChange in javascript

    - by shrimpy
    in one of my selection box, i have a onChange="..." specified... coz i want to change some other form value after any selection changes. however ... in the same page, some wired case i have to manually set the value.. so i have to use some javascript to set the value of the selection combox, but in this case, i don`t want that onChange event to be fired... how can i walk around it??? Forgot to mention that i am actually using dijit.form.comboBox. for normal HTML form comboBox, it won`t cause any issue. Only i use the dijit comboBox, and i try to set the value to some other value, dojo will trigger the onChange.

    Read the article

  • jQuery .val Enigma between two input boxes

    - by Matt
    I'm trying to get it so that if I move a red div-square around the screen using jQuery UI and jQuery, then an input field updates with the position of the div. I got that working with a simple .val. But, it's hard to explain why, but I need to make it so that when I move the square, it updates my input box, and when the input box value is changed, another input box reflects the new value of the old input box. Do I make any sense, coz I'm confusing myself :). I made a jsfiddle, so perhaps it'll make more sense there. If you move the red square, then the input box directly above it updates, but the input box above that does not, even though it is programmed to reflect the value of the input box below itself. P.S. Is this specific to only jQuery, or is this problem present in all of JavaScript. Thanks! http://jsfiddle.net/xmCsq/27/

    Read the article

  • Prototype to JQuery - how to access originator of event

    - by ciaranarcher
    Hi there I'm coming from a Prototype background and looking into JQuery. I'd like to know the 'right' way to do attach a click event to a bunch of elements, but then know in the event handler which one of my elements was clicked. I've come up with the following: MYNS.CarouselHelper.prototype.attachImgHandlers = function () { $j(".carouselItem").bind("click", this, function(e){ e.data.openCarouselImage(e) }); } I then have the following in my event handler: MYNS.CarouselHelper.prototype.openCarouselImage = function(e) { var img = e.currentTarget; // Do stuff to the image element }; Is this 'right'? It feels wrong to me as I am used to explicitly passing the element to the event handler in Prototype as I loop through an array of elements. Thanks in advance.

    Read the article

  • Transform any JavaScript function into a page event

    - by Laith
    I need to be able to achieve the following (one way or another): function ShowContent() {} document.onShowContent = function () { // anything I want to happen.... } What I'm trying to do is to add a kind of listener to me Advertisement code on the page that will auto refresh the ad slot when a specific function is called. Instead of having that function "ShowContent()" directly refresh the ad code, I want the ad code to refresh if it detects that "ShowContent()" has been called. Thanks.

    Read the article

  • IPhone Objectvie C

    - by Sea
    I am trying to determine if a UILabel was touched and if so do something. Give .. . . . UILabel * site = [[UILabel alloc] initWithFrame:CGRectMake(0, 185, 320, 30)]; site.text = [retriever.plistDict valueForKey:@"url"]; site.textAlignment =UITextAlignmentCenter; site.backgroundColor = [UIColor clearColor]; site.textColor = [UIColor whiteColor]; site.userInteractionEnabled = YES; [theBgView addSubview:site]; [site release]; . . . Then I write the callback. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ retriever = [PListRetriever sharedInstance]; CGPoint pt = [[touches anyObject] locationInView: self]; NSURL *target = [[NSURL alloc] initWithString:[retriever.plistDict valueForKey:@"url"]]; [[UIApplication sharedApplication] openURL:target]; } The problem is right now, no matter where I touch in the View the Url is being opened. How do I determine if only just my label was touched?

    Read the article

  • Change button's enabled property via checkbox

    - by Ivan Stoyanov
    I tried this javascript but it doesn't work - here I need to change the button's enabled property to true when the checkbox is checked and to false when it isn't. This is my code. <tr> <td colspan="2" align="center"> <asp:CheckBox ID="cbAcceptAgreement" runat="server" OnClientClick="acceptAgreement(this)" /> <asp:Label ID="lblUserAgreement" runat="server" Text="I accept the " /> <asp:HyperLink ID="hlUserAgreement" runat="server" Text="User Agreement" NavigateUrl="Help/UserAgreement.aspx" /> </td> </tr> <tr> <td colspan="2" align="center"> <asp:Button ID="btnRegister" runat="server" Text="Register" /> </td> </tr> <script type="text/javascript"> function acceptAgreement(Obj) { document.getElementById('<%=btnRegister.ClientID%>').disabled = !obj.checked; } </script> Can you help me solve this problem?

    Read the article

  • IE not triggering keyboard event on a form with ONE FIELD

    - by raj
    I'm seeing my Friend's code here... <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> Check action </TITLE> <script> function detectEvent(){ if(window.event.keyCode==13) { alert("you hit return!"); } } </script> </HEAD> <BODY> <form name="name1" onkeyup="detectEvent()" action="page2.html"> <p> Field1 <input type="text" id="text1"/> </p> </form> </BODY> </HTML> and when he tried entering a value in the textbox and pressed enter, it did not call the detectEvent(). I said, it'll always call onSubmit on enter button..... and he surprised me, <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> Check action </TITLE> <script> function detectEvent(){ if(window.event.keyCode==13) { alert("you hit return!"); } } </script> </HEAD> <BODY> <form name="name1" onkeyup="detectEvent()" action="page2.html"> <p> Field1 <input type="text" id="text1"/> </p> <p> Field1 <input type="text" id="text2"/> </p> </form> </BODY> </HTML> Now press enter, The function gets called..... Why so!? Why onKeyUp not called on forms with just one field.!!! am i missing something?

    Read the article

  • Table data display in HTML

    - by Hulk
    In the following table how to adjust the height and width automatically for the table. i.e, if the data is more it should display all the data else present data ina fashionable manner <table="mytable"> <tr><td>more data.............................................................................</td> <td>a</td> </tr> In the nothing should be wrapped wither in case of large chuks of data or small chunks of data. Thanks....

    Read the article

< Previous Page | 93 94 95 96 97 98 99 100 101 102 103 104  | Next Page >