prototype

Does Low Pro Prototype DOM Builder work in IE?

Dan Webb's Low Pro UJS extension to Prototype offers the following elegant DOM Builder: var listItem = $li({ id : 'item-1' }, $strong("Some text") ); // returns a node equivalent to: <li id="item-1"><strong>Some text</strong></li> $('a_list').appendChild(listItem); While this works like a dream for u...

Prototype Ajax.PeriodicalUpdater inserts empty string when server unreachable.

I'm using the following to grab some updated HTML and insert it into a div with id "content" var updater = new Ajax.PeriodicalUpdater('content', '/Doc?'+d.getTime(), { method: 'post', frequency: 5, }); The problem is that when the server is shut down (it's running inside of an app that is modifying and server up the data),...

submit a form via Ajax using prototype and update a result div

Hello, I'm wondering how can I submit a form via Ajax (using prototype framework) and display the server response in a "result" div. The html looks like this : <form id="myForm" action="/getResults"> [...] <input type="submit" value="submit" /> </form> <div id="result"></div> I tried to attach a javascript function (which uses...

Can OpenLaszlo Use JavaScript Libraries like JQuery and PrototypeJS ?

I have been looking at OpenLaszlo and observed that scripting in the client is implemented in JavaScript. Does this mean it is possible to use libraries like JQuery and PrototypeJS ? ...

using JQuery and Prototype in the same page

Hi, Several of my pages use both JQuery and Protoype. Since I upgraded to version 1.3 of JQuery this appears to be causing problems, because both libraries define a function named '$'. JQuery provides a function noConflict() which relinquishes control of $ to other libraries that may be using it. So it seems like I need to go through a...

Is there an idiomatic way to listen for changes to the DOM using the Prototype library?

I'm trying to add a listener to DOM change events. I was hoping something as simple as 'dom:loaded' was baked into Prototype. I'm not sure of the 'Prototype-way' to handle this. EDIT: I cannot control every case in which the DOM may be altered, so I can't get away with firing a custom event on every DOM change. ...

<pre> tag loses line breaks when setting innerHTML in IE

I'm using Prototype's PeriodicalUpdater to update a div with the results of an ajax call. As I understand it, the div is updated by setting its innerHTML. The div is wrapped in a <pre> tag. In Firefox, the <pre> formatting works as expected, but in IE, the text all ends up on one line. Here's some sample code found here which illustr...

Hide/clear input field with prototype

Hy everyone, I have the following script : if (Object.isUndefined(Axent)) { var Axent = { } } Axent.SelfLabeledInput = Class.create({ initialize: function() { var labelSelector = arguments[0] || 'label'; $$(labelSelector).findAll(function(l) {return (l.readAttribute('for') !== null)}).each(function(l){ l.hide(); $(l.readAttr...

Ajax: Partial refresh of a parent page (update a div) from "lightbox" window

Is there a way to update information in a div of a parent page from a pop-up/"lightbox" window. I would like to create a pop up window that contains a form that updates a database (currently i am using php/mysql with prototype). In other words... I would like a user to be able to use a form in a popup window to update the database, and...

(Rails) What is "RJS"?

I've seen "RJS" and "RJS templates" mentioned in passing in blog posts and tutorials. I did a search, but I'm still unsure about it. Is it a technology specific to Rails, rather than a standard like JSON or YAML? I understand it's used for "generating JavaScript." Does it generate generic JS or Rails-specific JS requiring the Prototype ...

Trigger an event with Prototype

Does anybody know of a method to trigger an event in Prototype, as you can with jQuery's trigger function? I have bound an event listener using the observe method, but I would also like to be able to fire the event programatically. Thanks in advance ...

Javascript `this` not working as I thought?

I'm adapting a pretty basic js function into a class. Anyway, basically it just creates a floating container above the main page. I'm aware it's incomplete, but I'm in the middle of typing it up, and keep getting caught out when attempting to call the close() function. Firefox returns a this.sdiv is undefined. I'm confused as to how thi...

Does jQuery have an equivalent to Prototype's Element.identify?

Is there a built in method or defacto default plugin that will let you automatically assign an unique ID to an element in jQuery, or do you need to implement something like this yourself? I'm looking for the jQuery equivalent to Prototype's identify method Here's an example. I have some HTML structure on a page that looks like this <...

Books on Prototypal Inheritance

My work in JavaScript and Ajax programming has stimulated a renewed interest in prototypal inheritance. Can anyone recommend any good books on the subject? In particular, books that deal with languages that predate JavaScript. This seems to be a very poorly documented subject matter, which is why I'm asking here. ...

Prototype.js and associative arrays

I have an associative array (object) of the following construction var menu = new Object('Submenu A','Submenu B','Submenu C','Submenu D'); menu['Submenu A']=new Object(); menu['Submenu A']['Option A']= 'foo blah text'; menu['Submenu A']['Option B']= 'blah more text'; menu['Submenu B']['Option A']= 'blah blah'; menu['Submenu B']['Option ...

Canonical prototype-based object-oriented programming book?

I'm looking for a good book (or webpage, maybe) on prototype-based OO. In particular, I'm looking for something heavy on theory. Ideally, I don't want something language-specific (and I really don't want something about Javascript, but if everybody said "just read the Self manual" that's fine). Basically, is there a prototype-based eq...

Javascript private member on prototype...

Well I tried to figure out is this possible in any way. Here is code: a=function(text) { var b=text; if (!arguments.callee.prototype.get) arguments.callee.prototype.get=function() { return b; } else alert('already created!'); } var c=new a("test"); // creates prototype instance of getter var d=ne...

Getting the img tag inside iframe

I have an iframe with a class name="blaclass". Inside it, I have one div with no name (or id) and inside this id there is a div with class name = "classs". Inside this div, lie two images (with no class name/id). How can I get those image.src? If there is a Prototype version even better! PS: I cannot add class names/ids before the pag...

How do I create a new DOM element from an HTML string using built-in DOM methods or prototype

I'm trying to create an element dynamically using an HTML string. Here's a simple example using both prototype and DOM: // HTML string var s = '<li>text</li>'; // DOM var el1 = document.createElement(s); // prototype var el2 = new Element(s); $('mylist').appendChild(el1); $('mylist').appendChild(el2); Both approaches insert an empty ...

change layout on selection box change

Hi all, I want to render a partial depending on a selection in selection box. This looks trivial but I can't find an example. All help is greatly appreciated. Regards ...