Hi Guys, I''m converting some Mootools code to Prototype and am having problems. I''d like to instantiate an itemScroller Class that takes an html element as its first argument and a list of options as it''s second. The class has default options which can be overwritten. var itemScroller = Class.create({ options: { containerSelector: ''ul'', itemSelector: ''li'', viewPortSelector: ''.wrap'', scrollerSelector: ''.item_scroller'', nextSelector: ''.next'', prevSelector: ''.prev'', itemsPerScroll: 5, wrapEnds: false, mode: ''vertical'' }, initialize: function(el,options) { // quit if no main element passed in if (!$(el)) return; if ($(options)) this.setOptions(this.options, options); ..... }); itemScroller.implement(new Options); //Mootools code a separate script instantiates the Class when a click event fires: new itemScroller($(''#recent_list_holder''), { containerSelector: ''ul#recent_list'' }); Thanks for any help you can offer! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Try this: var ItemScroller = Class.create({ initialize: function(el,options) { // quit if no main element passed in if (!$(el)) return; this.options = Object.extend({ containerSelector: ''ul'', itemSelector: ''li'', viewPortSelector: ''.wrap'', scrollerSelector: ''.item_scroller'', nextSelector: ''.next'', prevSelector: ''.prev'', itemsPerScroll: 5, wrapEnds: false, mode: ''vertical''}, options || {}); } }); new ItemScroller(''foo''); new ItemScroller(''bar'', {itemsPerScroll:25}); -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, Justin! That works without errors, although other parts of the Class are still written in mootols and are causing problems, but thats for a different post. On May 20, 1:01 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Try this: > > var ItemScroller = Class.create({ > initialize: function(el,options) { > // quit if no main element passed in > if (!$(el)) return; > this.options = Object.extend({ > containerSelector: ''ul'', > itemSelector: ''li'', > viewPortSelector: ''.wrap'', > scrollerSelector: ''.item_scroller'', > nextSelector: ''.next'', > prevSelector: ''.prev'', > itemsPerScroll: 5, > wrapEnds: false, > mode: ''vertical''}, options || {}); > } > > }); > > new ItemScroller(''foo''); > new ItemScroller(''bar'', {itemsPerScroll:25}); > > -justin--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---