[Proto-Scripty] Infinite references
Hi, I'm creating a visual tree structure in which every item can have multiple childs. In the following code the parent item adds one child to itself. But for some reason the child adds itself as a child of its own in an infinite loop: - CODE -- var Item = Class.create({ column: null, text: null, childs: [], parent: null, initialize: function(column, text, parent) { this.column = column; this.text = text; this.parent = parent; }, addChild: function(child) { this.childs[this.childs.length] = child; } }); var startI = new Item(1, 'start', null); var vervolg1 = new Item(2, 'vervolg 1', startI); var vervolg2 = new Item(2, 'vervolg 2', startI); startI.addChild(vervolg1); startI.addChild(vervolg2); - You can find an image of the result (in the console) on http://www.bartblok.com/problem.PNG Why is this an infinite reference? The code should add vervolg1 and vervolg2 as childs of startI, but not childs of themselves. I hope someone can help me :) -- 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-scriptacul...@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: Infinite references
Hi, The problem is that your `childs` property is shared by all of your instances, it's not specific to each instance. You have the same problem that the OP has in this question from just a few days ago, so see that thread for the details of why: http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/85114620db0bdc0e You can fix it by removing the `childs: [],` line from your `Class.create` call and then adding: this.childs = []; ...in your `initialize` function. That will ensure that each instance has its own array. (Off-topic: In English, the plural of child is children, not childs. Although most English nouns are made plural by adding an s or es or even ses, quite a number of them are done differently.) Hope this helps, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Dec 8, 2:05 pm, Bart bblok...@gmail.com wrote: Hi, I'm creating a visual tree structure in which every item can have multiple childs. In the following code the parent item adds one child to itself. But for some reason the child adds itself as a child of its own in an infinite loop: - CODE -- var Item = Class.create({ column: null, text: null, childs: [], parent: null, initialize: function(column, text, parent) { this.column = column; this.text = text; this.parent = parent; }, addChild: function(child) { this.childs[this.childs.length] = child; } }); var startI = new Item(1, 'start', null); var vervolg1 = new Item(2, 'vervolg 1', startI); var vervolg2 = new Item(2, 'vervolg 2', startI); startI.addChild(vervolg1); startI.addChild(vervolg2); - You can find an image of the result (in the console) onhttp://www.bartblok.com/problem.PNG Why is this an infinite reference? The code should add vervolg1 and vervolg2 as childs of startI, but not childs of themselves. I hope someone can help me :) -- 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-scriptacul...@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: Observe once
Hi, Provided the code is in the order you're showing it and you don't assign some other value to `discardAll` later, that should work; here's a stand-alone example (not using Lightview, but using custom events): http://jsbin.com/awiqi4 Somewhat off-topic, but unless you have a good reason to do the function expression (`var discardAll = function`...), use a function declaration instead (`function discardAll`...), as here: http://jsbin.com/awiqi4/2 But it doesn't matter for the problem you've outlined, unless the code is in a different order than shown. FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Dec 7, 3:56 pm, Luke kickingje...@gmail.com wrote: Hi, I'm doing an internship in a company where they bought a script for modals called 'Lightview' (http://www.nickstakenburg.com/projects/lightview/ ), so I'm kinda stuck with using it. The problem is that instead of many other libraries, you cannot pass lightview any callbackfunctions as parameters. That means the only way to react on, lets say, when lightview is done opening or closing is to observe global events that will be fired in such cases. So if I want to do something when lightview closes I need to observe 'lightview:hidden', but I do not -always- react on this event with a given behaviour since there are many cases for which lightview is shown. I just want to react to the close even just this one time. So I thought, maybe I could write an observer, that kills its self after it has been executed. I tried this: var discardAll = function(event) { // Do stuff document.stopObserving('lightview:hidden', discardAll); } document.observe('lightview:hidden', discardAll); But this doesn't work. I must say I don't really have much clue of stoping specific observers in the first place, so I'm wondering if this is even the right way to stop an observer Thanks, Lukas -- 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-scriptacul...@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.
Re: [Proto-Scripty] Re: Infinite references
On 9 December 2010 09:27, T.J. Crowder t...@crowdersoftware.com wrote: Hi, The problem is that your `childs` property is shared by all of your instances, it's not specific to each instance. You have the same problem that the OP has in this question from just a few days ago, so see that thread for the details of why: http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/85114620db0bdc0e You can fix it by removing the `childs: [],` line from your `Class.create` call and then adding: this.childs = []; ...in your `initialize` function. That will ensure that each instance has its own array. (Off-topic: In English, the plural of child is children, not childs. Although most English nouns are made plural by adding an s or es or even ses, quite a number of them are done differently.) Hope this helps, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Dec 8, 2:05 pm, Bart bblok...@gmail.com wrote: Hi, I'm creating a visual tree structure in which every item can have multiple childs. In the following code the parent item adds one child to itself. But for some reason the child adds itself as a child of its own in an infinite loop: - CODE -- var Item = Class.create({ column: null, text: null, childs: [], parent: null, initialize: function(column, text, parent) { this.column = column; this.text = text; this.parent = parent; }, addChild: function(child) { this.childs[this.childs.length] = child; } }); var startI = new Item(1, 'start', null); var vervolg1 = new Item(2, 'vervolg 1', startI); var vervolg2 = new Item(2, 'vervolg 2', startI); startI.addChild(vervolg1); startI.addChild(vervolg2); - You can find an image of the result (in the console) onhttp://www.bartblok.com/problem.PNG Why is this an infinite reference? The code should add vervolg1 and vervolg2 as childs of startI, but not childs of themselves. I hope someone can help me :) http://pastebin.com/gZ97fiH7 shows the fix T.J. is recommending. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY -- 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-scriptacul...@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] Altering information beofre submitting to field
Hi, i am rather new to autocomplete and i have run across a problem. Ive tried google but the mass of information is intimidating. My probem is that i want to the dropdownlist from the auocompletion to display more information than what will actualy be submitted to the field. i have a list of IDs complete with a discription of the IDs and i want the ID and discription to appear in the dropdown list but i only want the ID to be submitted to the form. How do i accomplish this, thanks in advance, Linus -- 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-scriptacul...@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.
Re: [Proto-Scripty] Altering information beofre submitting to field
Take a look at the 'informal' option in the Wiki. If you code your drop-down with span class=informal wrapping the parts you don't want submitted, then you will get precisely what you're asking for. Walter On Dec 9, 2010, at 7:58 AM, Lincarte wrote: My probem is that i want to the dropdownlist from the auocompletion to display more information than what will actualy be submitted to the field. -- 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-scriptacul...@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: Altering information beofre submitting to field
Thank You Walter, using the infromation you gave me i was able to perform better google searches myself. The problem however is still usolved. I forgot to mention that i am working with Lotus Notes Domino Designer and i adding the informal attribute in the view removed the section entierly. am i missing something? Perhaps an option for the Autocompleter? On 9 Dec, 15:17, Walter Lee Davis wa...@wdstudio.com wrote: Take a look at the 'informal' option in the Wiki. If you code your drop-down with span class=informal wrapping the parts you don't want submitted, then you will get precisely what you're asking for. Walter On Dec 9, 2010, at 7:58 AM, Lincarte wrote: My probem is that i want to the dropdownlist from the auocompletion to display more information than what will actualy be submitted to the field.- Dölj citerad text - - Visa citerad text - -- 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-scriptacul...@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.
Re: [Proto-Scripty] Re: Altering information beofre submitting to field
What I see on the Wiki is the following: If you wish to display additional information in the autocomplete dropdown that you don’t want inserted into the field when you choose an item, surround it in a span (could work with others but not tested) with the class of “informal”. For instance, the following shows a list of companies and their addresses, but only the company name will get inserted: ul liACME Inc span class=informal 5012 East 5th Street/span/ li liScriptaculous span class=informal 1066 West Redlands Parkway/span/li /ul If you are working in the part of the view that generates the hints, then it appears you simply decorate the parts you want the visitor to see but the server not to see with a span class informal. Everything inside the li except the contents of that span will be sent to the server. Walter On Dec 9, 2010, at 9:55 AM, Lincarte wrote: Thank You Walter, using the infromation you gave me i was able to perform better google searches myself. The problem however is still usolved. I forgot to mention that i am working with Lotus Notes Domino Designer and i adding the informal attribute in the view removed the section entierly. am i missing something? Perhaps an option for the Autocompleter? On 9 Dec, 15:17, Walter Lee Davis wa...@wdstudio.com wrote: Take a look at the 'informal' option in the Wiki. If you code your drop-down with span class=informal wrapping the parts you don't want submitted, then you will get precisely what you're asking for. Walter On Dec 9, 2010, at 7:58 AM, Lincarte wrote: My probem is that i want to the dropdownlist from the auocompletion to display more information than what will actualy be submitted to the field.- Dölj citerad text - - Visa citerad text - -- 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 . -- 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-scriptacul...@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.