[Proto-Scripty] Need explanation
/* Based on Alex Arnell's inheritance implementation. */ var Class = { create: function() { var parent = null, properties = $A(arguments); if (Object.isFunction(properties[0])) parent = properties.shift(); function klass() { this.initialize.apply(this, arguments); } Object.extend(klass, Class.Methods); klass.superclass = parent; klass.subclasses = []; if (parent) { var subclass = function() { }; subclass.prototype = parent.prototype; klass.prototype = new subclass; parent.subclasses.push(klass); } for (var i = 0; i properties.length; i++) klass.addMethods(properties[i]); if (!klass.prototype.initialize) klass.prototype.initialize = Prototype.emptyFunction; klass.prototype.constructor = klass; return klass; } }; Class.Methods = { addMethods: function(source) { var ancestor = this.superclass this.superclass.prototype; var properties = Object.keys(source); if (!Object.keys({ toString: true }).length) properties.push(toString, valueOf); for (var i = 0, length = properties.length; i length; i++) { var property = properties[i], value = source[property]; if (ancestor Object.isFunction(value) value.argumentNames().first() == $super) { var method = value; value = (function(m) { return function() { return ancestor[m].apply(this, arguments) }; })(property).wrap(method); value.valueOf = method.valueOf.bind(method); value.toString = method.toString.bind(method); } this.prototype[property] = value; } return this; } }; --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Limit depth of Sortable Tree
I'm attempting to make a list of grouped terms. I'm approaching this by creating a Sortable object as a tree, so the user will be able to drag terms into and out of groups, as well as reordering the groups themselves. I do not want the user to be able to drag a group into another group. I was wondering if there was an option (or a workaround) for limiting the depth of a Sortable tree. Another idea I had about solving this was to make the Droppable 'group' elements only accept terms (since accept is an option for the Droppable class). Although, since creating the draggable and droppables is all done when calling Sortable.create, I'm not sure how I can modify the options for individual elements. Any ideas? Kevin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Getting the value of a selected option
I've got a standard select box with options, and the select box has an id of theme_choice I've found the following script online, but it isn't popping up an alert when a selection is made: $$('#theme_choice').each(function(elem){ if (elem.selected) alert(elem.text + ' ' + elem.value); }); Prototype is called just before this in the head area of the page. I'm using the latest version RC3. This is for a theme changer script on my website. I have a current theme changer script, but I'm trying to play around with prototype. I don't know if it is spam to put a link to my website or reference it, so I won't, but the select box with options is really just a standard form element. Nothing special. Thanks for your help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Sortable lists don't drag smoothly with newer versions of scriptaculous
Hi there, I have a sortable UL list using scriptaculous, nothing fancy or unusual. When I use an older version of the dragdrop.js file (e.g. v1.5), it works as expected. The dragging of list elements to sort them, is smooth. When I use the latest version and try to drag a list element, it's jerky and feels delayed. There is a ticket for a similar problem (with links to demo pages): https://prototype.lighthouseapp.com/projects/8887/tickets/168-sortable-trees-are-not-working-well-in-the-current-version However this ticket is referring to sortable trees (nested lists), so the fixed posted isn't applicable (I tried it anyway, just in case!) If anyone has any suggestions or fixes it would be greatly appreciated! Cheers, Emily --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Any way to access class attributes when using 'each' to iterate over an array?
Hi, Within the function called by #each, by default the context (the this value) is a reference to the global object ('window', on web browsers), not the same context as the code calling #each. This is how JavaScript functions work: Unless you do something to explicitly set this when calling them, they default to this being the global object. More on this in this blog entry[1]. Because of that, #each has a second parameter[2] that sets the context to use when calling the function. So this would work: var Deletr = Class.create({ initialize: function(options) { this.list = new Array(); $$('a.deletr').each(function(element) { this.list.push(element); }, this); } }); All I did there was add the second parameter to #each. BTW, slightly OT, but you could replace that entire loop with this line of code: this.list = $$('a.deletr'); Unlike DOM methods, Prototype's various DOM wrappers return arrays, not live lists, so you don't have to make a copy. If you really did want to make a copy for some reason, you could do that via the $A function[3] rather than an #each loop. [1] http://blog.niftysnippets.org/2008/04/you-must-remember-this.html [2] http://prototypejs.org/api/enumerable/each [3] http://prototypejs.org/api/utility/dollar-a HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jul 7, 10:50 pm, David Behler d.beh...@gmail.com wrote: Why does this work: var Deletr = Class.create({ initialize: function(options) { var list = new Array(); $$('a.deletr').each(function(element) { list.push(element); }); } }); But this does not? var Deletr = Class.create({ initialize: function(options) { this.list = new Array(); $$('a.deletr').each(function(element) { this.list.push(element); }); } }); Firebug reports: this.list is undefined this.list.push(element); Is there a way to access class attributes when I'm using each to iterate over an array? That would be really helpful! Thanks David --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Getting the value of a selected option
Hi, I've found the following script online, but it isn't popping up an alert when a selection is made: You're not asking it to. :-) You're asking it to pop up an alert if something is selected at the moment you're calling that code; you haven't hooked up an event handler. To make it happen when something is selected, you'll need to observe the 'change' event (probably). You probably also want $('theme_choice') rather than $$ ('#theme_choice')[1][2]. More here[3][4]. [1] http://prototypejs.org/api/utility/dollar [2] http://prototypejs.org/api/utility/dollar-dollar [3] http://prototypejs.org/api/element/observe [4] http://prototypejs.org/api/event/observe HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jul 8, 3:44 am, skunkbad iamsen...@gmail.com wrote: I've got a standard select box with options, and the select box has an id of theme_choice I've found the following script online, but it isn't popping up an alert when a selection is made: $$('#theme_choice').each(function(elem){ if (elem.selected) alert(elem.text + ' ' + elem.value); }); Prototype is called just before this in the head area of the page. I'm using the latest version RC3. This is for a theme changer script on my website. I have a current theme changer script, but I'm trying to play around with prototype. I don't know if it is spam to put a link to my website or reference it, so I won't, but the select box with options is really just a standard form element. Nothing special. Thanks for your help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Any way to access class attributes when using 'each' to iterate over an array?
Thanks alot! That worked! I already guessed it had something to do with the context but didn't know how to change it... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Animated Ajax Record Deletion
Thanks! That worked! I'm still a beginner and trying to really get into Prototype...good to know people here are willing to help :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: IE 6.0.2900.2180.xpsp_sp2_rtm.040803-2158 Problem
Andy Wenk schrieb: Hi everybody, I am new to the list and this is my first post. Actually we have a problem wit the Internet Explorer 6.0.2900.2180.xpsp_sp2_rtm.040803-2158. We are not able to localize the problem and try now to figure out wheter it could be a Javascript Problem or anything else. The site is running on one of our servers (PHP, PostgreSQL ...). A company is calling this site via https:// out of their company's network. The employees are only allowed to use the IE 6.0.2900.2180.xpsp_sp2_rtm.040803-2158. In a random turn the user gets a DNS error page saying, that the DNS Server is not reachable. The page where that happens is a simple html page with a login form. The login form is submitted with $('form_name').submit(). As I said befor - sometimes it works - sometimes not. Even on one machine with the same IE version are no problems at all and on another one are these problems. Are there any known problems with exactly this version of IE? Especially with https:// ? We don't think that the error has anything to do with Javascript or our programming. But we have to make sure that this is a fact and not just our idea ... Every comment is higly appreciated. Cheers Andy For the archive - it was not a javascript error. IE 6 in this version has a lousy SSL implementation. This worked with apache 1.3. Since apache 2.x was changed, you have to use a special configuration for IE 6 to avoid this problem. Furthermore we assume, that it was also a combination of the proxy configuration plus the IE 6 the company uses ... So the solution was to change the apache settings - no javascript or prototype error ;-) Cheers Andy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] process further
Hello On return from a ajax call with prototype, is it possible to send the return parameters to a function to be processed first and then write that return value to the designated element? Also where is the syntax on how to write the return values? I am having difficulty understanding what I can use as text and what I can use as a variable. tia. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: process further
I guess you would have to use Ajax.Request to process the returned value before updating the designated element. But I'm beginner and could be wrong here. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: process further
Hi David Thanks, but I think I one step further. I am assuming an Ajax.request() has happened, returned and what I am looking at to understand further is syntax like this: $('fullName').value = json.fullName; for an returned parameter fullName and an html element ID of fullName. I am wondering, can I do $('fullName').value =processMe( json.fullName); which I know the obvious is try it. I will, just trying to get an heads up. I will report back. Also I am assuming that prototpye is processing that nomenclature $('fullName') segment and just doing a document.getElementById. Any insight appreciated. On Wed, Jul 8, 2009 at 12:25 PM, David Behler d.beh...@gmail.com wrote: I guess you would have to use Ajax.Request to process the returned value before updating the designated element. But I'm beginner and could be wrong here. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: process further
Hello, all you have to do (I guess) is set a callback to onComplete. Something as follow: // onComplete callback's call function processJsonPart (myCoolVar) { // do something with your returned JSON return myCoolVarEvaluatedOrValidatedOrAnythingYouWant; } // here we call Ajax.request function clickButtonExample() { new Ajax.Request(url, { onComplete: function(r) { var json = r.responseText.evalJSON(true); $('name').value = foo(json.name); } } } PS: untested functions. On Wed, Jul 8, 2009 at 11:37 PM, chrysanthe mchrysant...@gmail.com wrote: Hi David Thanks, but I think I one step further. I am assuming an Ajax.request() has happened, returned and what I am looking at to understand further is syntax like this: $('fullName').value = json.fullName; for an returned parameter fullName and an html element ID of fullName. I am wondering, can I do $('fullName').value =processMe( json.fullName); which I know the obvious is try it. I will, just trying to get an heads up. I will report back. Also I am assuming that prototpye is processing that nomenclature $('fullName') segment and just doing a document.getElementById. Any insight appreciated. On Wed, Jul 8, 2009 at 12:25 PM, David Behler d.beh...@gmail.com wrote: I guess you would have to use Ajax.Request to process the returned value before updating the designated element. But I'm beginner and could be wrong here. -- Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: process further
oops! 'foo' should be 'processJsonPart' On Thu, Jul 9, 2009 at 1:38 AM, Douglasdouglas.gont...@gmail.com wrote: Hello, all you have to do (I guess) is set a callback to onComplete. Something as follow: // onComplete callback's call function processJsonPart (myCoolVar) { // do something with your returned JSON return myCoolVarEvaluatedOrValidatedOrAnythingYouWant; } // here we call Ajax.request function clickButtonExample() { new Ajax.Request(url, { onComplete: function(r) { var json = r.responseText.evalJSON(true); $('name').value = foo(json.name); } } } PS: untested functions. On Wed, Jul 8, 2009 at 11:37 PM, chrysanthe mchrysant...@gmail.com wrote: Hi David Thanks, but I think I one step further. I am assuming an Ajax.request() has happened, returned and what I am looking at to understand further is syntax like this: $('fullName').value = json.fullName; for an returned parameter fullName and an html element ID of fullName. I am wondering, can I do $('fullName').value =processMe( json.fullName); which I know the obvious is try it. I will, just trying to get an heads up. I will report back. Also I am assuming that prototpye is processing that nomenclature $('fullName') segment and just doing a document.getElementById. Any insight appreciated. On Wed, Jul 8, 2009 at 12:25 PM, David Behler d.beh...@gmail.com wrote: I guess you would have to use Ajax.Request to process the returned value before updating the designated element. But I'm beginner and could be wrong here. -- Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense. -- Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---