Hi,
Basically what I'm after is, following squashing all my JavaScript into one file (or a few files) how can I make a document.observe(dom:loaded({...})) function call for the right page?
So, say I have 5 pages in my website, and each one has a separate JS file. Inside each file is a load of page related functions, and a special funct...
I am trying to call a method from the constructor of my javascript constructor, is this possible and if so, I can't seem to get it working, any insight would be great! Thanks!
function ValidateFields(pFormID){
var aForm = document.getElementById(pFormID);
this.errArray = new Array();//error tracker
this.CreateErrorList();
}
...
I'm new to prototypal inheritance so I'm trying to understand the 'right' way. I thought I could do this:
if (typeof Object.create !== 'function') {
Object.create = function (o) {
function F() {}
F.prototype = o;
return new F();
};
}
var tbase = {};
tbase.Tdata = function Tdata() {};
tbase.Tdata.protot...
These Prototype <-> jQuery slides gave a great comparison between ajax libraries, but are based on Prototype 1.6 and jQuery 1.2.1.
Now that jQuery is at version 1.4.2, has there been changes in its fundamentals? I skimmed its release notes for recent versions and saw mostly API changes and performance enhancements.
...
Hello.
function A() {
this.myProp = document.createElement("div"); }
function B(id) {
this.myProp.id = id;
document.body.appendChild(this.myProp); }
B.prototype = new A();
window.onload = function() {
new B("hello");
new B("goodbye"); }
What happens here is that I end up with one div with id "goodbye". What I wo...
Hi,
This is driving me nuts. Its a tough one to explain but Ill have a go.
I have one input text field on the front page of my site. I have coded a keydown event observer which checks the keyCode and if its ENTER (or equiv), itll check the input value (email). If the email is valid and unique in the DB itll submit the form. Basic stuff...
Hi,
I want to upload a file using an ajax request
var xhr = new XMLHttpRequest();
xhr.open("POST", "/photos");
xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');
xhr.sendAsBinary(bin);
Works fine, but I want to post a parameter with this request ie: token=abc123
How can give a parameter to this request?
this is pu...
Hi,
Is there a way to write the following pure javascript in prototypejs
var xhr = new XMLHttpRequest();
xhr.open("POST", "/photos?authenticity_token=" + token
+ "&photo[name]=" + img.name
+ "&photo[size]=" + img.size);
xhr.overrideMimeType('text/plain; charset=x-user-defined-binary');...
i am trying to call a remote method to update page content via ajax/js.
either i am too tired already or haml is not parsing the following code correctly to send the value of the query field via prototype. any ideas?
- form_remote_tag(:url => {:controller => "search", :action => "line"},:with => "'query=' + $('query').value" ) do
%inp...
I'm using prototype to make Ajax requests. Occasionally the responses contain malformed XML. Prototype is using the onException callback, but the first error that is thrown is when I am trying to access a particular node.
I know Firefox recognizes the malformed response, because if I request the xml via the address bar, Firefox presents...
Hi there!
I need to use JQuery in order to detect the changes on a text file, so some ajax is invoked.
The trick is that I don't really want to bind this action to the blur or keyup events; The former is too cumberstone for the user and the second is "too inmediate": the user types new keys before the ajax call has been completed, so t...
I dont know if this is even possible, but I have a situation where I need to be able to hide the previous table row onload.
Situation:
<table>
<tr>
<td>1</td>
<td>a</td>
</tr>
<tr>
<td>2</td>
<td>b</td>
</tr>
<tr id="removeabove">
<td>3</td>
<td>c</td>
</tr>
</table>
Now again I dont know if this is even p...
In Scriptaculous 1, you could animate styles:
new Effect.Morph('id', {
style: { background: tomato },
duration: '4' });
But a better way was to keep the CSS and JS separate and merely reference a class:
new Effect.Morph('id', {
style: 'important',
duration: '4' });
Marvellous. But this doesn't seem to work with the new Scripty 2. W...
I've got XML coming back from an Ajax.Request in Ajax.Response.responseXML. My XML actually contains XHTML tags which I hope to append into my document.
I'm having issues appending nodes from the responseXML into the current document, however. I suspect that this is because they are XML nodes and not DOM nodes.
Wrapping the responseXM...
Hi,
I have a prototype question in the context of Ruby on Rails.
QUESTION - In a rails view how do I trigger a remote AJAX call?
ie. like "link_to_remote" but directly without the link - so I want specifically in my case when the windows loads to be able to trigger a remote call to populate data in a DIV via a remote call...
thanks...
I am using scriptaculous to perform a slidedown effect using the following code:
Effect.SlideDown('dom_element_id');
I then hide the button which initiates this effect using:
$('button_id').hide();
The issue is that the button is hidden before the animation effect is complete, I would like it to hide after the animation effect is com...
Is there's any way how to reset styles back to what's in my CSS?
Example:
#foo {width: 50px; height: 50px; position: absolute; top: 150px; left: 250px;}
function moveFoo(newpostop, newposleft){
$('foo').setStyle({top: newpostop+'px', left: newposleft+'px'});
}
Now when I'm done with it, I'd like to move foo back when it was. I kn...
I'm trying to migrate from using inline event triggers to using event listeners using Prototype's Event.observe function. There are a few inline commands that I don't know how to handle using the function call.
I want to move from:
<form id='formFoo' action='whatever.php' onsubmit="return Foo.verify(this);">
To an event call:
Event....
function f()
{
}
alert (f.prototype); // returns something like [object Object]
My understanding is by default the prototype of custom function should be null or undefined, can someone shed some light? thanks!
See also: How does __proto__ differ from constructor.prototype?
...
How do you form a collection of all the listeners and functions for a given Element using prototype?
Also, is there a simple way to do this with normal Dom listeners on a given Element?
thanks
...