Search Results

Search found 12948 results on 518 pages for 'mouse events'.

Page 157/518 | < Previous Page | 153 154 155 156 157 158 159 160 161 162 163 164  | Next Page >

  • Ruby/Rails - Add records to an object with each loop iteration / Object vs Arrays

    - by ChrisWesAllen
    I'm trying to figure out how to add records to an existing object for each iteration of a loop. I'm having a hard time discovering the difference between an object and an array. I have this @events = Event.find(1) @loops = Choices.find(:all, :limit => 5) #so loop for 5 instances of choice model for loop in @loops @events = Event.find(:all,:conditions => ["event.id = ?", loop.event_id ]) end I'm trying to add a new events to the existing @events object based on the id of whatever the loop variable is. But the ( = ) operator just creates a new instance of the @events object. I tried ( += ) and ( << ) as operators but got the error "You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil" I tried created an array events = [] events << Event.find(1) @loops = Choices.find(:all, :limit => 5) #so loop for 5 instances of choice model for loop in @loops events << Event.find(:all,:conditions => ["event.id = ?", loop.event_id ]) end But I dont know how to call that arrays attributes within the view With objects I was able do create a loop within the view and call all the attributes of that object as well... <table> <% for event in @events %> <tr> <td><%= link_to event.title, event %></td> <td><%= event.start_date %></td> <td><%= event.price %></td> </tr> <% end %> </table> How could i do this with an array set? So the questions are 1) Whats the difference between arrays and objects? 2) Is there a way to add into the existing object for each iteration? 3) If I use an array, is there a way to call the attributes for each array record within the view?

    Read the article

  • Control within another control in asp.net disables server-side events?

    - by Xaisoft
    I have a control which has a button on it. All the button does is redirect the user to another page. On this control I have another control which just display some stuff, nothing fancy. When I click on the button, it does nothing. When I remove or comment out the other control, the button event works. Is this by design? I am not sure how to fix it or what is causing it. ControlA.ascx contains a button with an event like so: protected void Button1_Click(object sender, EventArgs e) { Response.Redirect("~/Home.aspx"); } ControlA.ascx contains another control inside of it, lets call it ControlB.ascx. The Button1 click event does not fire when ControlB.ascx is in ControlA.ascx, but when I remove it or take it out, Button1 event fires and it goes to Home.aspx. This does not only happen for Button1, if I decide to add a second button and create an event for it, if ControlB is in ControlA, the second button event won't fire either.

    Read the article

  • jquery: adding class on to list-items only on mouseover-remove on mouse-out?

    - by user239831
    hey guys, what's the best way to do that: i have a list <ul> <li>hello</li> <li>good bye</li> <li>arrivederci</li> <li class="selected">dude</li> <li>whatever</li> </ul> Initially one item already has a class of .selected applied. When i hover over one of the list-items i want this one to have the .selected class. So every item should only have the class applied when im over, as soon as i leave the item the class get's removed and the next one has the class.

    Read the article

  • how sequence events while upload heavy file to Amazon S3 ?

    - by coolpawan4u
    Here i am getting problem while uploading heavy files e.g. 100MB. Files go to amazon s3 successfully but after that scripts waiting for if($flag == 1) and does not execute the rest of code. Can any one tell me the solution for this ? if($s3-putObjectFile($uploadDIR, $bucket, $name, S3::ACL)) { $flag = 1; } if($flag == 1) { //countine code }

    Read the article

  • How can I add a border to all the elements that share a class when the mouse has hovered over one of

    - by Siracuse
    I have a generated HTML file which has large blocks of text with span's sprinkled throughout it with generated class names: This <span class="21232">an example</span> of what <span class="332423"> I'm talking</span> about. There are span's with <span class="21232"> generated ID's </span>. Now, what I'm seeking to do, is if I hover over any of my spans, they will add a border to not only that span, but all other spans that share that same class. So, if I were to hover over the first span, it would wrap a border around "an example" and "generated ID's" because the first and third span share the same class name. I was pretty sure I couldn't do it in straight CSS. Is this possible using jQuery? If so, can anyone point me in the right direction for doing this as simply as possible?

    Read the article

  • How can I prevent infinite recursion when using events to bind UI elements to fields?

    - by Billy ONeal
    The following seems to be a relatively common pattern (to me, not to the community at large) to bind a string variable to the contents of a TextBox. class MyBackEndClass { public event EventHandler DataChanged; string _Data; public string Data { get { return _Data; } set { _Data = value; //Fire the DataChanged event } } } class SomeForm : // Form stuff { MyBackEndClass mbe; TextBox someTextBox; SomeForm() { someTextBox.TextChanged += HandleTextBox(); mbe.DataChanged += HandleData(); } void HandleTextBox(Object sender, EventArgs e) { mbe.Data = ((TextBox)sender).Text; } void HandleData(Object sender, EventArgs e) { someTextBox.Text = ((MyBackEndClass) sender).Data; } } The problem is that changing the TextBox fires the changes the data value in the backend, which causes the textbox to change, etc. That runs forever. Is there a better design pattern (other than resorting to a nasty boolean flag) that handles this case correctly? EDIT: To be clear, in the real design the backend class is used to synchronize changes between multiple forms. Therefore I can't just use the SomeTextBox.Text property directly. Billy3

    Read the article

  • Is there a way to set a handler function for when a set of events has happened in JavaScript?

    - by allyourcode
    eg I have two concurrent AJAX requests, and I need the result from both to compute a third result. I'm using the Prototype library, so it might look something like this: var r1 = new Ajax.Request(url1, ...); var r2 = new Ajax.Request(url2, ...); function on_both_requests_complete(resp1, resp2) { ... } One way would be to use polling, but I'm thinking there must be a better way.

    Read the article

  • is it possible to make one click fires two events or more by javascript?

    - by NewInAlbert
    I am currently making a temporary download page for website visitor. The page includes a form, after the visitor fills the form up, the site will take them to the pdf download page. In the download page, there are some pdf files download links (I am just using a tag.). However, i wanna make a onclick event to those links, once they have been clicked, the page will refresh automatically or redirect to other pages. <a href="/file.pdf" onClick="window.location.reload()">The File</a> I have tried the jquery way as well. <a href="/file.pdf" id="FileDownload">The File</a> <script> $("#FileDownload").click(function(){ location.reload(); }); </script> But all the them are not working. Do you masters have any good ideas about this, many thanks. P.S. What if I wanna add a countdown after a file is being started download, and then do page reload when countdown finishes. Looks like have asked several questions... Thanks a ton in advance.

    Read the article

  • Rails 3 respond_with, route constraints and resources

    - by Intelekshual
    I'm building a versioned API, so I have the following nested controllers: ApiController < ApplicationController Api::V1Controller < ApiController Api::V1::EventsController < Api::V1Controller The API is accessed via a subdomain. I have the following routes: constraints(:subdomain => "api") do scope :module => 'api' do namespace :v1 do resources :events end end end This produces the type of URL I want (/v1/events). The problem I'm facing is when using responds_with in Api::V1::EventsController. Just doing something as simple as the below fails with the error too few arguments: def index @events = Event.all respond_with(@events) end I know respond_width is meant to be used with resources, but I'm not sure how the events resource should be accessed from the constrained, scoped, and namespaced route. I can output other things (such as current_user), just not an array of events. Help?

    Read the article

  • Stopwatch vs. using System.DateTime.Now for timing events

    - by Randy Minder
    I wanted to track the performance of a piece of my application so I initially stored the start time using System.DateTime.Now and the end time also using System.DateTime.Now. The difference between the two was how long my code took to execute. I noticed though that the difference didn't appear to be accurate. So I tried using a Stopwatch object. This turned out to be much, much more accurate. Can anyone tell me why Stopwatch would be more accurate than calculating the difference between a start and end time using System.DateTime.Now? Thanks.

    Read the article

  • Using Javascript to detect the bottom of the window and ignoring all events when a request is loading

    - by Aaron Reba
    I have an anonymous function to detect the user has scrolled to the bottom of the window. Inside of the anonymous function, I have a call to a database that takes a while to complete. var allowing_more = 1; $(window).scroll(function() { if (allowing_more == 1){ if ($(window).scrollTop() + $(window).height() == $(document).height()) { allowing_more = 0; //query allowing_more = 1; } } }); In this time, if the user scrolls to the bottom of the window again, it seems a queue is made holding the occurences the user scrolled to the bottom of the window while the query was loading. Upon completing of the query, these occurences are then executed. I have a boolean statement to detect if the anonymous function is accepting more query requests but this seems to be ignored. Is there some sort of way to ignore an anonymous function temporarily and re-enable it?

    Read the article

  • html links & hover events over certain locations on an image.

    - by Tommy
    So i created a web site a long time ago using a designer alot like frontpage + expression design put together, and since then Ive gotten more into coding, and I'm learning html, CSS, and all that good stuff.. and i have this re-designed header that Ive made here: http://prntscr.com/8zct So what I need to know, is how i can get it so that when a user clicks on one of the links in the header design it will redirect to a page. and also if possible, how to make it so when a user hovers over a link a drop down may appear with other options. As me being quite new to this sort of stuff, could anybody help me achieve this? PS. I'm working in Visual Studio with ASP. but that doesn't change anything about the html and css stuff. just letting you guys know.

    Read the article

  • How do I add events to nested server controls? (ASP.Net)

    - by bert
    I am building a custom master page type control i.e. sort of like a datagrid but should be easier to add custom functionality into it. It's going great but part of the desired functionality is to have a paging control that switches on and off and part of that control would be a textbox that displays the current page number and on TextChanged redirects to the new page of the dataset. The problem I'm having is that technically the textbox which has its event fired is embedded in a control that is embedded in the control you actually put on the page sort of like Page  | Display Control  | Paging Control  | Textbox Buried all the way down there the event is not firing. Worse the postback javascript isn't even being written onto the page (Nothing on the page posts back so far this is the only bit that really needs to). I've been trawling around Google for quite a while now and picked up that I need to implement INamingContainer (done) and I need to add the control into the page's control tree (is Pre_Init too late for that? When's a good time to Add the Control to the page?) then the event should fire, apparently. But I've been unable to find an example of best practice on this there are quite a few near misses where people are having button angst but this isn't a button. So can anyone point me in the direction of getting a control embedded in a control embedded in a control added to a page to behave properly?

    Read the article

  • How to show hand cursor when mouse is over List component?

    - by Lost_in_code
    I am aware that the follow will show a hand cursor: component.mouseChildren = true; component.useHandCursor = true; component.buttonMode = true; When I do the above on a List component, the hand button is shown and the whole component loses it's interactivity (Hand cursor is shown even on scrollbars). So how can I show the hand cursor only when rolling over the list items?

    Read the article

  • jQuery does not execute on dynamically loaded content,, even on a click events.

    - by sxv
    I have two document.ready functions. The first loads content into div#header. The second one performs a hide function and then a toggle function on the newly loaded content. I am not sure if this is a queueing issue or something, but not even the alert() below is executed when I click the loaded content. Thanks. <script type="text/javascript"> $(document).ready(function() { $("#header").load("/documents/collegeradioheader.txt"); }); </script> <script type="text/javascript"> $(document).ready(function() { $(".hideme").hide(); $(".slick-toggle").click(function() { alert('hi'); $(this).parent().next('div').slideToggle('fast'); .siblings('div:visible').slideUp('fast'); }); }); </script>

    Read the article

  • Multiple setInterval in a HTML5 Canvas game

    - by kushsolitary
    I'm trying to achieve multiple animations in a game that I am creating using Canvas (it is a simple ping-pong game). This is my first game and I am new to canvas but have created a few experiments before so I have a good knowledge about how canvas work. First, take a look at the game here. The problem is, when the ball hits the paddle, I want a burst of n particles at the point of contact but that doesn't came right. Even if I set the particles number to 1, they just keep coming from the point of contact and then hides automatically after some time. Also, I want to have the burst on every collision but it occurs on first collision only. I am pasting the code here: //Initialize canvas var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), W = window.innerWidth, H = window.innerHeight, particles = [], ball = {}, paddles = [2], mouse = {}, points = 0, fps = 60, particlesCount = 50, flag = 0, particlePos = {}; canvas.addEventListener("mousemove", trackPosition, true); //Set it's height and width to full screen canvas.width = W; canvas.height = H; //Function to paint canvas function paintCanvas() { ctx.globalCompositeOperation = "source-over"; ctx.fillStyle = "black"; ctx.fillRect(0, 0, W, H); } //Create two paddles function createPaddle(pos) { //Height and width this.h = 10; this.w = 100; this.x = W/2 - this.w/2; this.y = (pos == "top") ? 0 : H - this.h; } //Push two paddles into the paddles array paddles.push(new createPaddle("bottom")); paddles.push(new createPaddle("top")); //Setting up the parameters of ball ball = { x: 2, y: 2, r: 5, c: "white", vx: 4, vy: 8, draw: function() { ctx.beginPath(); ctx.fillStyle = this.c; ctx.arc(this.x, this.y, this.r, 0, Math.PI*2, false); ctx.fill(); } }; //Function for creating particles function createParticles(x, y) { this.x = x || 0; this.y = y || 0; this.radius = 0.8; this.vx = -1.5 + Math.random()*3; this.vy = -1.5 + Math.random()*3; } //Draw everything on canvas function draw() { paintCanvas(); for(var i = 0; i < paddles.length; i++) { p = paddles[i]; ctx.fillStyle = "white"; ctx.fillRect(p.x, p.y, p.w, p.h); } ball.draw(); update(); } //Mouse Position track function trackPosition(e) { mouse.x = e.pageX; mouse.y = e.pageY; } //function to increase speed after every 5 points function increaseSpd() { if(points % 4 == 0) { ball.vx += (ball.vx < 0) ? -1 : 1; ball.vy += (ball.vy < 0) ? -2 : 2; } } //function to update positions function update() { //Move the paddles on mouse move if(mouse.x && mouse.y) { for(var i = 1; i < paddles.length; i++) { p = paddles[i]; p.x = mouse.x - p.w/2; } } //Move the ball ball.x += ball.vx; ball.y += ball.vy; //Collision with paddles p1 = paddles[1]; p2 = paddles[2]; if(ball.y >= p1.y - p1.h) { if(ball.x >= p1.x && ball.x <= (p1.x - 2) + (p1.w + 2)){ ball.vy = -ball.vy; points++; increaseSpd(); particlePos.x = ball.x, particlePos.y = ball.y; flag = 1; } } else if(ball.y <= p2.y + 2*p2.h) { if(ball.x >= p2.x && ball.x <= (p2.x - 2) + (p2.w + 2)){ ball.vy = -ball.vy; points++; increaseSpd(); particlePos.x = ball.x, particlePos.y = ball.y; flag = 1; } } //Collide with walls if(ball.x >= W || ball.x <= 0) ball.vx = -ball.vx; if(ball.y > H || ball.y < 0) { clearInterval(int); } if(flag == 1) { setInterval(emitParticles(particlePos.x, particlePos.y), 1000/fps); } } function emitParticles(x, y) { for(var k = 0; k < particlesCount; k++) { particles.push(new createParticles(x, y)); } counter = particles.length; for(var j = 0; j < particles.length; j++) { par = particles[j]; ctx.beginPath(); ctx.fillStyle = "white"; ctx.arc(par.x, par.y, par.radius, 0, Math.PI*2, false); ctx.fill(); par.x += par.vx; par.y += par.vy; par.radius -= 0.02; if(par.radius < 0) { counter--; if(counter < 0) particles = []; } } } var int = setInterval(draw, 1000/fps); Now, my function for emitting particles is on line 156, and I have called this function on line 151. The problem here can be because of I am not resetting the flag variable but I tried doing that and got more weird results. You can check that out here. By resetting the flag variable, the problem of infinite particles gets resolved but now they only animate and appear when the ball collides with the paddles. So, I am now out of any solution.

    Read the article

  • Flash video hiding the cursor on Mac OS X

    - by Tibor
    I found a Core Graphics function, CGCursorIsVisible, that one can use to determine whether the mouse cursor is shown on screen. I have a small app that uses a timer to call that function a few times a second to see if the cursor is shown or hidden (as I found no way to get my app notified when the mouse cursor shown/hidden status changes). The above works correctly except… when the Flash browser plugin plays a video: the mouse cursor gets hidden after a few seconds of mouse inactivity but CGCursorIsVisible() still keeps telling me that the cursor is indeed shown as if nothing happened. What I need is to be able to tell, at any given moment, whether the mouse cursor is shown to the end user on any screen. Is there any way to do that even in the case of playing a video using the Flash plugin?

    Read the article

< Previous Page | 153 154 155 156 157 158 159 160 161 162 163 164  | Next Page >