Are these libs compatible ? At the very least I''d like to be able to use Prototype & Dojo ? Thoughts welcome.. Matt _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Nothing really is compatible with prototype.js, becausue prototyps modifies some core javascript objects, nevertheless, you can use both together, it worked fine for me, just take care of the order of loading the libs ( prototype.js, then dojo.js) On 5/19/06, Matt Spendlove <mspendlove506-YDxpq3io04c@public.gmane.org> wrote:> > Are these libs compatible ? At the very least I''d like to be able to use > Prototype & Dojo ? > > Thoughts welcome.. > > Matt > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- Roberto Saccon _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I think this brings up the question of what is prototype.js NOT compatible with. I am curious if people have ran into issues with any of the common libraries like dojo, YUI, mochikit, etc.. Also, the core javascript object that prototype.js modifies that I have seen cause problems is the Array which causes problems for code like ''for(each in {Array}''. Are there any other issues with prototype.js. With that said, I still feel prototype.js is the most elegant js library around. Jake Roberto Saccon wrote:> Nothing really is compatible with prototype.js, becausue prototyps > modifies some core javascript objects, nevertheless, you can use both > together, it worked fine for me, just take care of the order of loading > the libs (prototype.js , then dojo.js) > > On 5/19/06, *Matt Spendlove* <mspendlove506-YDxpq3io04c@public.gmane.org > <mailto:mspendlove506-YDxpq3io04c@public.gmane.org>> wrote: > > Are these libs compatible ? At the very least I''d like to be able to > use Prototype & Dojo ? > > Thoughts welcome.. > > Matt > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > -- > Roberto Saccon > > > ------------------------------------------------------------------------ > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I believe the issue with the for loop was resolved quite a while ago. On 5/20/06, Jacob Rockowitz <thebigbluehouse-ihVZJaRskl1bRRN4PJnoQQ@public.gmane.org> wrote:> I think this brings up the question of what is prototype.js > NOT compatible with. I am curious if people have ran into > issues with any of the common libraries like dojo, YUI, > mochikit, etc.. > > Also, the core javascript object that prototype.js modifies > that I have seen cause problems is the Array which causes > problems for code like ''for(each in {Array}''. Are there any > other issues with prototype.js. > > With that said, I still feel prototype.js is the most > elegant js library around. > > Jake > > Roberto Saccon wrote: > > Nothing really is compatible with prototype.js, becausue prototyps > > modifies some core javascript objects, nevertheless, you can use both > > together, it worked fine for me, just take care of the order of loading > > the libs (prototype.js , then dojo.js) > > > > On 5/19/06, *Matt Spendlove* <mspendlove506-YDxpq3io04c@public.gmane.org > > <mailto:mspendlove506-YDxpq3io04c@public.gmane.org>> wrote: > > > > Are these libs compatible ? At the very least I''d like to be able to > > use Prototype & Dojo ? > > > > Thoughts welcome.. > > > > Matt > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > > > -- > > Roberto Saccon > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
The major issue that was resolved was with Object.prototype.extend which was adding the ''extend'' method to every object. (http://erik.eae.net/archives/2005/06/06/22.13.54/) Still, the Array object in prototype.js return unexpected results which includes all the enumeration methods. For example: var array = ["bob", "sally", "fred"]; for(each in array){ document.write(each + "<BR>") } returns: name value set exec indexOf without flatten compact ... BTW, I don''t think this is a ''problem'' but it can break existing javascript code. Also, I know using an Array as Hash/Object is just a bad idea, still people have made this mistake, including myself. This brings me back to my question, does prototype.js break any popular libraries? thanks ~jake Andrew Kaspick wrote:> I believe the issue with the for loop was resolved quite a while ago. > > On 5/20/06, Jacob Rockowitz <thebigbluehouse-ihVZJaRskl1bRRN4PJnoQQ@public.gmane.org> wrote: >> I think this brings up the question of what is prototype.js >> NOT compatible with. I am curious if people have ran into >> issues with any of the common libraries like dojo, YUI, >> mochikit, etc.. >> >> Also, the core javascript object that prototype.js modifies >> that I have seen cause problems is the Array which causes >> problems for code like ''for(each in {Array}''. Are there any >> other issues with prototype.js. >> >> With that said, I still feel prototype.js is the most >> elegant js library around. >> >> Jake >> >> Roberto Saccon wrote: >> > Nothing really is compatible with prototype.js, becausue prototyps >> > modifies some core javascript objects, nevertheless, you can use both >> > together, it worked fine for me, just take care of the order of loading >> > the libs (prototype.js , then dojo.js) >> > >> > On 5/19/06, *Matt Spendlove* <mspendlove506-YDxpq3io04c@public.gmane.org >> > <mailto:mspendlove506-YDxpq3io04c@public.gmane.org>> wrote: >> > >> > Are these libs compatible ? At the very least I''d like to be >> able to >> > use Prototype & Dojo ? >> > >> > Thoughts welcome.. >> > >> > Matt >> > >> > _______________________________________________ >> > Rails-spinoffs mailing list >> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> > <mailto:Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org> >> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> > >> > >> > >> > >> > >> > -- >> > Roberto Saccon >> > >> > >> > >> ------------------------------------------------------------------------ >> > >> > _______________________________________________ >> > Rails-spinoffs mailing list >> > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> _______________________________________________ >> Rails-spinoffs mailing list >> Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >> > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >
Hi, I have a basic question about Class.create() Vs creating objects. I would like to know the pros of one over the other (which one I don''t know). Problem Description: I would like to write an object "Browser" that has methods like getName, getVersion... I could do it any of the following ways - var Browser = { this.getName: function() { }, this.getVersion: function() { } }; Or I could do - var Browser = Class.create(); Browser.prototype = { initialize: function() { }, getName: function() { }, getVersion: function() { } } In the first case when I created an object, I can use it as Browser.getName() whereas in the second case when I used Class.create(), I need to first do new Browser(); Browser.getName(); Just want to know if it''s a good idea or a bad one to create classes and not objects? Could there be memory problems with too many classes? Thanks, Mandy.
With the first method you are creating one static object, with the second you have a method of creating as many instances of that object as you need. You pick the one that best suits your need. On 21/05/06, Maninder, Singh <mandiv@corp.untd.com> wrote:> Hi, > > I have a basic question about Class.create() Vs creating objects. > > I would like to know the pros of one over the other (which one I don't know). > > Problem Description: > > I would like to write an object "Browser" that has methods like getName, getVersion... > > I could do it any of the following ways - > > var Browser = { > this.getName: function() { > }, > this.getVersion: function() { > } > }; > > Or I could do - > > var Browser = Class.create(); > Browser.prototype = { > initialize: function() { > }, > getName: function() { > }, > getVersion: function() { > } > } > > In the first case when I created an object, I can use it as Browser.getName() > whereas in the second case when I used Class.create(), I need to first do > > new Browser(); > Browser.getName(); > > Just want to know if it's a good idea or a bad one to create classes and not objects? > > Could there be memory problems with too many classes? > > Thanks, > Mandy. > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs >-- Andrew Tetlaw htp://tetlaw.id.au _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On 5/21/06, Maninder, Singh <mandiv-W2hqgAdRMsX2eFz/2MeuCQ@public.gmane.org> wrote: Not all OOP concepts translate very well to JavaScript, but here''s how I treat them.> I could do it any of the following ways - > > var Browser = { > this.getName: function() { > }, > this.getVersion: function() { > } > };This is really creating a namespace called Browser than has the functions getName and getVersion.> Or I could do - > > var Browser = Class.create(); > Browser.prototype = { > initialize: function() { > }, > getName: function() { > }, > getVersion: function() { > } > }This is creating a class that will later be instantiated. It can have state and return results /for the object itself/ (through instance variables). All Class.create() is really doing is providing a call to <object>.initialize() when a new object is instantiated. You could theoretically still call Browser.getName() and Browser.getVersion(), but then you''re not taking advantage of initialize() and you shouldn''t bother with Class.create(). Todd
On Sunday 21 May 2006 02:53, Maninder, Singh wrote: [snip]> In the first case when I created an object, I can use it as > Browser.getName() whereas in the second case when I used Class.create(), I > need to first do > > new Browser(); > Browser.getName();not necessarily. With Class.create() (and I''m sure with just using regular javascript prototyping) you can have instance methods AND class methods, like in ruby. See for example, the following test page I threw together: http://edge/~kitchen/class.html I implemented a class with Class.create() called Testing, and defined some class methods and instance methods and then instantiated an instance of Testing and made some calls :) -Jeremy _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Jeremy, it looks like your URL is using an internal address (your workstation name?) On 5/21/06, Jeremy Kitchen <kitchen@scriptkitchen.com> wrote:> On Sunday 21 May 2006 02:53, Maninder, Singh wrote: > [snip] > > In the first case when I created an object, I can use it as > > Browser.getName() whereas in the second case when I used Class.create(), I > > need to first do > > > > new Browser(); > > Browser.getName(); > > not necessarily. With Class.create() (and I'm sure with just using regular > javascript prototyping) you can have instance methods AND class methods, like > in ruby. > > See for example, the following test page I threw together: > http://edge/~kitchen/class.html > I implemented a class with Class.create() called Testing, and defined some > class methods and instance methods and then instantiated an instance of > Testing and made some calls :) > > -Jeremy > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > >_______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
My validation lirary does this too: http://tetlaw.id.au/view/blog/really-easy-field-validation-with-prototype/ var Validation = Class.create(); Validation.prototype = { /*define instance methods*/}; Object.extend(Validation, {/*define class methods*/} On 22/05/06, Ed C. <defeated2k4@gmail.com> wrote:> Jeremy, it looks like your URL is using an internal address (your > workstation name?) > > On 5/21/06, Jeremy Kitchen <kitchen@scriptkitchen.com> wrote: > > On Sunday 21 May 2006 02:53, Maninder, Singh wrote: > > [snip] > > > In the first case when I created an object, I can use it as > > > Browser.getName() whereas in the second case when I used Class.create(), I > > > need to first do > > > > > > new Browser(); > > > Browser.getName(); > > > > not necessarily. With Class.create() (and I'm sure with just using regular > > javascript prototyping) you can have instance methods AND class methods, like > > in ruby. > > > > See for example, the following test page I threw together: > > http://edge/~kitchen/class.html > > I implemented a class with Class.create() called Testing, and defined some > > class methods and instance methods and then instantiated an instance of > > Testing and made some calls :) > > > > -Jeremy > > > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > > > > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- Andrew Tetlaw htp://tetlaw.id.au _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
On Sunday 21 May 2006 17:34, Ed C. wrote:> > See for example, the following test page I threw together: > > http://edge/~kitchen/class.html > > Jeremy, it looks like your URL is using an internal address (your > workstation name?)oops, I always forget that.. that or the port number (stupid adelphia) http://edge.scriptkitchen.com:81/~kitchen/class.html -Jeremy -- Jeremy Kitchen ++ kitchen-RA8HwDor7flnDGu+y90WmgC/G2K4zDHf@public.gmane.org http://ipaction.org/ -- defend your rights to fair use _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs