prototype

What is the difference between javascript obj.onclick and prototype's Event.observe(obj, 'click',fn) ?

What is the difference between javascript obj.onclick and prototype's Event.observe(obj, 'click',fn) ? ...

how come i can find hundreds of exmaples of jquery slideshow navigation and zero w/ prototype/scriptaculous?

magento comes bundled with scriptaculous so i figured i'd use those for a simple slideshow with navigation to jump between slides. -what a mistake, i can't find anything other than pause/play controls. Why? EDIT: To clarify what i mean by "jump between slides" is - i'm looking for buttons like 1 2 3 4 NOT pause, prev, next. Thanks! ...

Cannot find click observe Element

I have following event on button click I am unable to find element i.e,Source Element in code Event.observe(Generic_Large_Blue, 'click', moZoltarCurrent.evt_ZoltarOnSubmit.bindAsEventListener(moZoltarCurrent, Item_TextArea, PriceInBox), false); evt_ZoltarOnSubmit: function(e) { var sourceElement = Event.element(e)...

Hoverable tooltips with AJAX-pulled content on Prototype/Scriptaculous (to act like Twitter's)`

Twitter recently added hoverable multi-media "tooltips" -- when you hover over a username or avatar on your feed, it pops up (in-place) more details on the user (tweets sent/received, location, last tweet). It also includes a "Follow" button. There's a 'more-info' link which will load some more details on-demand. I'd like to emulate ho...

BindAsEventListener Problem in Prototype

var Generic_Large_Blue = new Element('div', { 'id': 'divZoltarSubmit_', 'class': 'Generic_Large_Blue Blue_' + placeholder }); var Generic_Large_Blue_Left = new Element('div', { 'class': 'Generic_Large_Blue_Left' }); var Generic_Large_Blue_Middle = new Element('div', { 'class': 'Generic_Large_Blue_Middle' }); var G...

How to pass argument if event handler is assigned in initialization function?

It is always good to separate presentation layer and behaviour between HTML and Javascript based on head first book. They tell me not to do: <textarea onclick="showAlert()"></textarea> But instead, do below: The example below separate the behaviour from HTML code (structure). <html> <head> <script type="text/javascript"> window.on...

Obvserving blur event for select Prototype

I have <div id="myselect"> <select> <option value="0">1</option> <option value="1">2</option> </select> </div> Im trying to get the value of the select on blur. So far I have: Event.observe('#myselect select', 'blur', function(event) { //get value }); Please advise! ...

Where is the problem in this prototype [ajax.Request] code ?

function sendM() { new Ajax.Request("sendm.html", { method: 'post', postBody: 'text='+ $F('text') +'&sub='+ $F('subject') +'&sname='+ $F('name') +'&sfmail='+ $F('email') +'to='+ $F('to'), onLoading:showLoad, onComplete: showResponse }); } function showLoad(){ $('dresult').innerHTML= "מבצע את הפעולה &nbsp;&nbsp;<br /><br />";...

Prototype and Ajax Search in Wordpress

So I got this code from http://www.elliotswan.com/2007/06/27/better-than-live-ajax-wordpress-ready-search-version-2/ and it works great for live search. The problem I'm having is that when a new search is made while there are results shown it should bindup the results, change to the new results, and then binddown the list of new results....

Ruby on Rails sortable_element serialization returns [id] instead of the actual id

Whenever I click the serialize button to return results I'll get something like "tree_list[0][id]=2&tree_list[1][id]=3...". View: <a href="#" onclick="alert(Sortable.serialize('tree_list'));return false">Serialize</a> <ul id="tree_list"> <%= render :partial => "tree_item", :collection => @tree_items %> </ul> <%= sortable_element('tree...

prototype update method to COPY vs MOVE

i am using prototypes update method. what i notice is that when it updates the receiving element with the providing elements innerHtml, the providing elements innerHtml is removed. not only the innerHtml, but the entire element. is it possible to retain both the element AND the innerHtml? so basically i just want to COPY the innerHtm...

Object OOP Vs Prototype OOP

Which OOP style do you think leads to more structred and efficent code? ...

When objects (e.g. img tag) is created by javascript, it doesn't have the closing tag. How do I make it W3C valid?

Image tag (<img src="" alt="" />), line break tags (<br />), or horizontal rule tags (<hr />) have the slashes at the end to indicate itself as self-closing tags. However, when these objects are created by javascript, and I look into the source, they don't have the slashes, making them invalid by W3C standards. How can I get over this p...

Chrome, Javascript, JSON and __proto__ -- where are my methods?

I've got a function: function createOrLoadDB (host) { var db = JSON.parse( window.localStorage.getItem(host) ) if ( db == null ) { db = new InitDB(host) } else { ...

Create a Hash with an Array

Hi, I've an Array ['red', 'green', 'blue'] I want to create a new Hash from this Array, the result should be {'red':true, 'green':true, 'blue':true} What is the best way to achieve that goal I use prototypejs 1.7_rc2 Thanks ...

using JavaScript how to capture all XMLHttpRequest onreadystatechange ?

Hi all, I am developing an extension from Chrome and I need to do some changes to the page code after it is loaded. but the problem is window.onload event isn't useful nowadays where almost any website is using AJAX. You can't assume that all content is already loaded because window.onload is fired before all AJAX request has done loadin...

Add an event listener to an object that is added to the DOM via AJAX

Hi There, I've got a set of checkboxes that are added to a document via an Ajax call <input type='checkbox' checked class='import'> <input type='checkbox' checked class='import'> <input type='checkbox' checked class='import'> <input type='checkbox' checked class='import'> <input type='checkbox' checked class='import'> I've got a few...

Dependent Selects in prototype

Hi, I have two <select>s with the same <option>s, and I need - using prototype - that when selecting an option in one of them, the same option is removed from the other select and additionally the latter must mantain its previously selected option. Any clues ? Is there a better way than remembering the last item selected, recreate the o...

IE v. FF: Is table.tBodies[0] valid?

From what I gather, tBodies[0] seems to work in IE, but not FF. Is this an IE mistake? I've created a small file to demonstrate the incosistency, and I would like to know the best way to go about this. The HTML: <html> <body> <table id="dataGrid"> </table> <input type="button" onclick="insertRow();" value="New row"> </body> </html...

My dilemma involving JavaScript's Prototypal Inheritance and the hasOwnProperty method

Basically everyone writing about member enumeration in JavaScript heavily advocates the use of the hasOwnProperty method as to avoid going up the prototype-chain. I understand that this is a form of defensive programming as to prevent iterating over members that are added, for example, to the Object.prototype. But what about the other...