prototype

Dynamic form generation without using nested models

Good day! I am a newbie at Ruby on Rails, and part of my previous tasks was to make a dynamic form generator using nested models, as seen in Railscasts 196 and 197 ( http://railscasts.com/episodes/197-nested-model-form-part-2 ). I have successfully implemented it using so. For my current task, however, I need to reproduce the same form m...

How to calculate if mouse pointer at bottom page using Prototype?

I want to create auto-hide menu, just the same thing like http://www.ringvemedia.com/shanghai-photos but the problem is that I also have content that is scrolling down so if I calculate pointerY it will return mouse absolute position so it could be 1000...999999 depends on how many content you have to scroll down, that why I cant use som...

Effect.toggle and AJAX Calls

Hi, I am using the following code to capture all the AJAX calls being made from my app, in order to show a busy spinner till the call is completed. It works well when the requests are well spaced out. However, when the request are made in quick successions, some of the AJAX calls do not get registered, or the onCreate and onComplete act...

Passing in number, Number.prototype.format

I've seen this format function referenced on several sites, but none of them have an explicit example of how to pass in a number into the function. I've tried '12345'.format('0.00') which I believe is how it should be written, but it gives me the error that the object doesn't support the property or method. I've also tried Number('1234...

Loading non-RJS javascript via ajax in Rails

I've written a rails module that generates some javascript for a google map. As the user makes changes on the webpage, I use observe_field to call back to the server to regenerate the map's javascript (without updating the whole page). I'm having trouble finding a good way to insert the new javascript into the page. I've tried <div id=...

fastest public web app framework for quick DB apps?

I'd like to pick up a new tech for my toolbox - something for rapid prototyping of web apps. Brief requirements: public access (not hosted on my machine) - like Google's appengine, etc no tricky configuration necessary to build a simple web app host DB access (small storage provided) including some kind of SQLish query language easy f...

fire link onclick events and follow href from javascript

I have a page defining a link ('a' tag) and some onclick events associated with it. I am trying to add an arbitrary HTML element (in this case a div) with the ability to respond to click events by firing the click events of the link. The code below describes all that. The end goal is to trigger exactly the same actions whether the cli...

ajax partial load from another page

So what I want to do is load only a section of one webpage onto another page. So I want to grab the content of a page (stuff inbetween a div with a certain id) without the headers and footers. I know I've seen this before but its, stangly, a hard thing to find. Anyone kind enough to point me in the right direction? thank you ...

Event not triggering

I have no idea where to start on this one. I have a <div> that does not appear until a button is clicked. This function call works: onclick="highlight('mod_sup_div', true);" function highlight(aDiv,show) { if (show) { Effect.Appear('Overlay',{duration: 0.5, to: .80}); Effect.Appear(aDiv,{duration: 0.5}) } ...

How do you get an ID of a clicked div element in JavaScript?

So my question is how to get an ID of an element that has just been clicked? (JavaScript) Thank you for your answers! ...

How to receive XMLHttpRequest with PHP?

I would like to be able to read XMLHttpRequest that is sent to a PHP page. I am using prototype's Ajax.Request function, and I am sending a simple XML structure. When trying to print the POST array on the PHP page, I don't get any output. Any help appreciated. EDIT: Below is my code <html> <head> <SCRIPT type="text/javascript" src...

Can Ruby on Rails's RJS give out static Javascript code to handle user interaction?

So it looks like on RoR, when Ajax (using form_remote_tag) returns a success code, Javascript is also returned to handle the visual effects. (this is the RJS mechanism) using Fiddler, I do see the following response: try { Element.update("vote_score", "Score 58"); $("vote_score").visualEffect("highlight"); } catch (e) { alert('RJS erro...

Prototype 'on show' Event.observe handler

I am trying to make an AJAX request that updates a div's content when that div is shown. My initial thought was to use an Event observer that watched for a div to be shown, but I cannot seem to find an appropriate handler. Is there an easy way to make an AJAX request for an element 'on show?' ...

Horizontally-centering an absolute position to match a relative position

I'm trying to make a div box, containing various elements, fixed at the top of the page once the page has been scrolled so that the box would normally be out of view, but scroll normally until that point (like the behaviour at http://perldoc.perl.org/perl.html). The conditionally-fixed part is pretty simple to implement (set the positio...

get days of a month in JS/Prototype

Hi, I´m looking for a function/prototype extension, which returns all days of a given month. I couldn't find anything helpful at the standard date() functions (http://www.w3schools.com/jsref/jsref_obj_date.asp). i.e.: getDays(2010-05) // returns something like: { day:'Saturday', date:'2010-01-05' }, { day:'Sunday', date:'2010-...

Prototype - DOM Traversal with up()

I have the following structure: <form> <div class="content"> ... </div> <div class="action"> <p>Select <a class="select_all" href="?select=1" title="Select All">All</a></p> </div> </form> I am using Prototype's up() to traverse the DOM in order to find the <form> element in respect to the a.select_all. ...

How do I pass an argument to a remote function when the argument value is not known until after render?

My html.erb template has this: function f(arg) { <%= remote_function :url => { :controller => "the_controller", :action => "the_action" }, :update => 'the_div', :method => :post %> ;} I'd like to do something like :id => arg or :with => "'arg=...'" ... but I don't know what the value of arg is until after the page has rendere...

Dynamic path in new.AjaxRequest with Rails

Hello, I was wondering if there's anyway to get a 'dynamic path' into a .js file through Ruby on Rails. For example, I have the following: new Ajax.Request('/tokens/destroy/' + GRID_ID, {asynchronous:true, evalScripts:true, onComplete:function(request){load('26', 'table1', request.responseText)}, parameters:'token=' + dsrc.id + '&authe...

Get an array of forms in java script using prototype

My document contains more than one forms. How can I get an array of all forms using prototype? <html> <head></head> <body> <form id="form1"> <!-- Other stuffs here --> </form> <form id="form2"> <!-- Other stuffs here --> </form> <form id="form3"> <!-- Other stuffs here --> </form> </body> </html> ...

Pushing elements into array as copy

In prototypejs, why does the following code remove the matching divs from the #test div? What confuses me is that this happens when they are being inserted in the #droparea, and not when they are being pushed in the array. <div id="test"> <div class="foo" id="22.1234"> 1 </div> <div class="foo" id="22.1235"> ...