[Proto-Scripty] Re: getElementByTagName - object doesn't support property...
$F gets the value of a form element, not the element itself. You're feeding a string into that function, and strings don't have the getElementsByTagName method. Use $ instead. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/5YJYNaeiUPcJ. 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.
Re: [Proto-Scripty] Re: ajax.updater - json to fill select
Updater expects the return result to be (X)HTML. It drops the response directly into the container as is. You should be returning an HTML string, or using Ajax.Request to get the JSON, convert it into HTML and dropping it in place. If you want to be hackish about it, you do your converting in your OnSuccess, then save it to the .responseText property on the transport. But that's like hammering a nail with a screwdriver. -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/VklwMFVGNUdXcTRK. 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.
Re: [Proto-Scripty] how-to add option to select
try using Ajax.Request -- You received this message because you are subscribed to the Google Groups Prototype script.aculo.us group. To view this discussion on the web visit https://groups.google.com/d/msg/prototype-scriptaculous/-/QTllMU5xRkRZMllK. 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: wierd setStyle Backgroundimage happenings..
ahh, both very good ideas. I will try the path change one first, then the class change if that does not work. Thank you guys. -- 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] wierd setStyle Backgroundimage happenings..
I have read the other post in this group where they were having issues with the setStyle background image code, but I am still having trouble getting this to work. It appears to be executing the setStyle background code but instead of changing to the specified image, it changes to no background image and stays that way. I have a mouse over listener and mouseleave listener, when the mouseenter is triggered, the bg changes to nothing, and when the mouseleave is triggered, the bg stays as nothing. I have included the div CSS so you can see the that i am using the correct file paths. A div callled 'zoom' has a mouseleave and mouseenter listener, which trigger the background of 'featured' to change accordingly, basically making it so the rollover effect of 'zoom' is extended to 'featured'. I have tried several different variations of the JS to make this work, but with no success. CSS of div to change bg-image of. #featured { height: 304px; width: 719px; margin-bottom: 6px; margin-top: 4px; background-image: url(../images/site/border_main.png); background-repeat: no-repeat; } #featured:hover { background-image: url(../images/site/border_main_ro.png); background-repeat: no-repeat; cursor:pointer; } JS of listeneres Event.observe($(zoom), 'mouseover', function() { $(featured).setStyle({background : 'url(../images/site/ border_main_ro.png)'}); }); Event.observe($(zoom), 'mouseleave', function() { $(featured).setStyle({background : 'url(../images/site/ border_main.png)'}); }); do you see why this setstyle is not working? or perhaps know a better way of extending rollover functionality between seperate divs? Thanks, Matt -- 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: Finding the position of a scroll bar for an element with overflow:auto
yeah, try $(myContainer).scrollTop On Nov 7, 5:10 pm, Shane McCarron halindr...@gmail.com wrote: I have an element that has overflow:auto. The contents of the element are updated from time to time via ajax calls. I want to ensure that when this happens, if the user has scrolled down into the content, their scroll position stays the same even through the content is effectively regenerated. Is there a way to get the scrollTop for an element? -- Shane McCarron halindr...@gmail.com -- 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] Rails UJS data-remote fires on any click
Hello, I was wondering if was intentional for ajax links (link_to ... :remote = true ... ) to fire on any click. I want links to behave where a left click fires of the ajax request, but a right click can allow you to copy link location or open in a new tab, depending on your browser. I found that in firefox, you get the context menu on a right click, but the action fires off anyway, not waiting for the user to decide what they want to do on the right click. Same behaviour for a middle click, which in some browsers would normally open up a new tab. I was able to modify rails.js around line 133 to test if this is a left click before handling the event in the usual manner. 133 document.on(click, a[data-remote], function(event, element) { 134 if (event.stopped) return; 135 // If loop inserted for left click only behaviour 136 if (event.button == 0) { 137 handleRemote(element); 138 event.stop(); 139 } 140 }); My main question is... is this going to hurt my site in any way? Also, is this something worthy of submitting a ticket over (if so, where) and if not, what was the idea behind making links fire off on any type of click. Thanks a lot, -- Matthew Smart -- 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: Variables in $$() ?????
Thanks for that but like most things in the prototype documentation, it lacks the type of clarity that I can understand. Nice way to get help... Your docs suck so just spoon feed me the answer The answer to your initial approach is an issue with basic javascript string behavior and was nailed on the head by both Johnathon and David var myVariableValue = 3; var mySelector = input[type=radio][name='type'] [value='myVariableValue']; In the above expression the value of myVariableValue isn't evaluated, its literally written into the string as is, hence its not the value 3 its the string value myVariableValue Hope you like puree'd corn template var myTemplate = new Template(input[type=#{type}][name='#{name}'] [value='#{value}']); var dto = { type : 'radio', name : 'type', value : '3' }; var selector = myTemplate.evaluate(dto); On Sep 25, 6:28 pm, T.J. Crowder t...@crowdersoftware.com wrote: The fundamental thing you need to do is _simplify_, divide and conquer. Is it the XML stuff that isn't working, or is it the radio button stuff that isn't working? Walk through with a debugger, etc. The `$$` of this is not the problem barring some strange thing, you'll need to look elsewhere. -- T.J. On Sep 25, 4:16 pm, Phil Petree phil.pet...@gmail.com wrote: Morning TJ! I know it SHOULD work... I'm just saying it didnt. works: // set radio button for type selectThis = {selectID: 'type', selectValue: transport.responseXML.getElementsByTagName('type')[0].firstChild.nodeValue} ; $$(radioTemplate.evaluate(selectThis))[0].writeAttribute(checked, checked); didn't work: var selectThis = transport.responseXML.getElementsByTagName('type')[0].firstChild.nodeValue; $$(input[type=radio][name='type'][value=' + selectThis + ']).writeAttribute(checked, checked); ALSO: This works: selectThis = {matchString: transport.responseXML.getElementsByTagName('state')[0].firstChild.nodeValue }; $$('select#ajstate option').each(function(o){ if(o.value == selectTemplate.evaluate(selectThis)){o.selected = true;$break;} }); But moving it into a function doesn't: setSelect('ajState', transport.responseXML.getElementsByTagName('state')[0].firstChild.nodeValue ); function setSelect(strID, strValue) { var selectIDTemplate = new Template('#{matchID}'); var selectTemplate = new Template('#{matchString}'); var selectThis; var selectID; selectID = {matchID: strID}; selectThis = {matchString: strValue }; $$('select#selectIDTemplate.evaluate(selectID) option').each(function(o){ if(o.value == selectTemplate.evaluate(selectThis)){o.selected = true;$break;} });} I think I am either daft or extremely tired! LOL On Sat, Sep 25, 2010 at 10:34 AM, T.J. Crowder t...@crowdersoftware.comwrote: Hi, David, although your suggestion doesn't throw any errors, it doesnt work either... kinda wierd as I thought it would... It does work, barring there being something wrong somewhere else: http://jsbin.com/elota3 The problem with your original code was as as Jonathan said, you were passing the string input[type=radio][name='type'][value=selectThis] into $$ as the selector. David's suggestion fixes that by using the *value* of selectThis rather the actual text selectThis. As the live example above shows, that works. FWIW, -- T.J. Crowder Independent Software Engineer tj / crowder software / com www / crowder software / com On Sep 25, 2:21 pm, Phil Petree phil.pet...@gmail.com wrote: David, although your suggestion doesn't throw any errors, it doesnt work either... kinda wierd as I thought it would... and it would have been MUCH simpler to implement too! On Sat, Sep 25, 2010 at 8:57 AM, David Behler d.beh...@gmail.com wrote: What about this: $$(input[type=radio][name='type'][value=' + selectThis + ']) ? Am 25.09.2010 14:41, schrieb Phil Petree: Jonathan, Thanks for that but like most things in the prototype documentation, it lacks the type of clarity that I can understand. IOW, I can read the documentation, scratch my head and say huh? I leave that documentation thinking this might be what I need but have no clue as to how to implement that to solve my problem. Which is exactly what happened here... OK, I need to use templates to somehow sprintf the string constant into a direct value but huh? On Sat, Sep 25, 2010 at 7:59 AM, Jonathan Rosenberg j...@tabbysplace.orgwrote: You're passing a string constant to $$ input[type=radio][name='type'][value=selectThis]) 'selectThis' will not be evaluated, as you seem to be expecting. Have a loook at Tenplate to do what you want: http://www.prototypejs.org/api/template -- Jonathan Rosenberg Founder Executive Director
[Proto-Scripty] Re: Passing Variables to Functions in addEventListener Within a Class
You can just add parameters to the bind call and they will show up in execution. $(id).observe('mousedown', this.myFunction.bind(this, otherParam); Then I believe it shows up after the event. function myFunction(event, param){... but in your case, simply binding to this will allow you to reference the instance's ID and all other properties associated with the class instance and you shouldn't have to basically curry extra parameters to the event listener. -- http://positionabsolute.net On Jul 23, 2:48 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Since you're creating the event handler inside your `initialize` function, you can take advantage of the fact it's already a closure by assigning `this` to a local variable (`self` is a common name for it) and then using `self` within the closure (the event handler), since it will inherit it. Here's an example (with a few other things cleaned up as well, I've included comments): initialize: function(id,name,top,left){ var self = this; // Keep a reference to the instance for use below try{ this.id = id; this.name = name; this.currentTop = top; this.currentLeft = left; // Use `observe`, not `addEventListener`, for IE support $(id).observe(mousedown, function(event) { // `event` not `this.id` // Throughout, use `self` to refer to the instance alert(self.id); self.myFunction(self.id); }); // No `false` needed with `observe` } catch(error){alert(error);} }, Alternately, if you don't like using `self`, or if the function you want to use is already defined somewhere, you can use Prototype's Function#bind. #bind creates a closure for you behind the scenes that will turn around and call the original function such that `this` is set correctly: initialize: function(id,name,top,left){ try{ this.id = id; this.name = name; this.currentTop = top; this.currentLeft = left; // Use `observe`, not `addEventListener`, for IE support $(id).observe(mousedown, (function(event) { // `event` not `this.id` alert(this.id); this.myFunction(this.id); }).bind(this)); // Note the `bind` (and as above, no `false` needed with `observe`) } catch(error){alert(error);} }, More on closures here:http://blog.niftysnippets.org/2008/02/closures-are-not-complicated.html More on `this` and how it's not the same in JavaScript as in some other languages:http://blog.niftysnippets.org/2008/04/you-must-remember-this.html More on binding here:http://api.prototypejs.org/language/function/prototype/bind/http://proto-scripty.wikidot.com/prototype:tip-using-an-instance-meth... HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Jul 23, 6:16 pm, Doc Torbin mtor...@gmail.com wrote: I am working on a class now and part of the initialization is adding event listeners to an object. I'd like to pass some value through to the functions that are attributes of the class but I can't seem to figure it out. Here's a sample piece of the code: var MyClass= new Class.create(); MyClass.prototype = { initialize: function(id,name,top,left){ try{ this.id = id; this.name = name; this.currentTop = top; this.currentLeft = left; $(id).addEventListener(mousedown,function(this.id){ alert(this.id); this.myFunction(this.id); },false); } catch(error){alert(error);} }, myFunction:function(event){ this.mouseState++; $('status').innerHTML = The object has been picked up. || mouseState is + this.mouseState; } }; Any suggestions would be much appreciated. - MT -- 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: Ajax abort method
I did something similar in that I just patched Ajax.Request with some extra functionality to allow timeouts, I never fussed with it further than fundamental tests but it certainly worked. Take a peak and maybe you can learn how to write something to meet your own needs http://positionabsolute.net/blog/2008/07/prototype-ajax-request-timeout.php On Jul 22, 5:29 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, There's a ticket for it:https://prototype.lighthouseapp.com/projects/8886/tickets/302 and it's mentioned in this one:https://prototype.lighthouseapp.com/projects/8886/tickets/308 Looks like #302 is waiting for someone to write some tests, but: I know that separate from Mark's stuff in #308, there's going to be an Ajax API rewrite (and possibly implementation rewrite as well) for 2.0. -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Jul 22, 8:09 am, Ran Berenfeld berenfeld...@gmail.com wrote: I'm sure this was asked before. I'm running a web site with continuous ajax calls to the same server page. Now I want that if the Ajax is not completed in (say) 5 seconds, the call will be aborted and a new call s made. I've seen pages in the web that suggests an implementation for an abort method. Will there be one in the upcoming release ? And should this method be used ? Thanks Ran Site Admin -http://www.ichess.co.il -- 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: How do I remove and stash an observer?
just store the reference to the listener and re-attach it to the element after the user has successfully purchased more comment tokens or whatnot. var myListener = function(){}; $(button).stopObserving(); //.. user buys tokens... $(button).observe('click', myListener); -- http://positionabsolute.net On Jul 21, 4:26 pm, Walter Lee Davis wa...@wdstudio.com wrote: I have a video editing app that I'm working on where you can add captions to your movie up to a total number of purchased captions. When you reach that limit, I disable the buttons that add more captions by using Element.stopObserving and changing the button image to reflect this disabled nature. Now the client would like me to add purchase more to the same screen, so I would like to know if I can memoize the listener from an element, disable it, and then re-enable it from memory later in the same session. I know that this page will work the way it is if I reload the page after a successful purchase of new captions, but it's a big page, and I'd like to avoid that if I can. Any ideas? Thanks, Walter -- 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] referencing div when class event triggered.
Hello, I am trying to figure out how to reference a specific div after it has been mouseOver, when i have an observe on a class-name that a bunch of div's share. The reason for this i want the code to be expandable where i can have multiple boxes with the same class, sharing all CSS properties, without having to sequentially id each div, and have X amount of observes; one for each specific div. So the basic JS would be something like: $$('.className'),observe('mouseover', funcToCall(way_to_reference_div) ); with a bunch of div's coded in html like: div class=className/div div class=className/div div class=className/div ... i understand if i have to add an id to each specific div, but i want a way to reference the id from a single observe statement that works for all div's sharing that class. Thanks, -- 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: morph effects on menu roll-over.. better way?
for anyone who has emailed me regarding seeing the code for the solution; i dont like posting code for project that have not been released, but i can give you the jist o the solution so you can apply it to your specific needs. I got everything (information wise) i needed to figure out the queue from the same link that joe.t posted above. (http://wiki.github.com/ madrobby/scriptaculous/effect-queues) read everything on that page to understand how it works first, but the important parts i used were the Effect.ScopedQueue and the clearing function: var queue = Effect.Queues.get('myscope'); queue.each(function(effect) { effect.cancel(); }); I used separate scoped queues for each item to be morphed, and when a rollover happened, it would clear the entire specific queue for an item, then add the new morph event to the queue. When a rollout happened it would also clear the entire specific queue for the item, then add the new morph event to the queue to be completed. This makes sure that when a new morph event it triggered on an item, it eliminates ALL OTHER morph events on that item, so there are never more than one morph event in queue on a specific item. This eliminates flickering caused by too many morph events being triggered and running/ending at different times. And it stops any other events that may have gotten mis-placed in the general queue from too many triggers being set off consecutively. Hope this helps, ill post the code after i publish the site this will be used for. -- 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: morph effects on menu roll-over.. better way?
I tried putting the morph calls in parallel and it really just changed the responsiveness of the rollover affect making it more 'stiff' and less fluid when multiple menu items were selected in succession. The affect i am trying to get it achieved by my first script (currently running on the test page), the only problem is it seems that the computer loses track of which order the morphs are called in. ex: when new morphs are called on dividers already in a morph process, it seems to overwrite the current morph with the new one, the new morph completes, then the divider flashes white as if it was still running the original morph command in the background and you just see the final result after the secondary overwriting morph has finished. im not sure if this is actually what is going on, its just the best way i can think of to explain the situation. it almost seems like a queue is required to ensure that the morphs complete in the proper order, and are canceled and re-ordered as the menu item selection changes, or maybe just canceling the previous morph on an element before ordering the new one (if that is not automatically done by javascript).. any one have any ideas/experience working with complex multiple morphing situations like this, or perhaps offer an alternative to using morph to complete the effect i want to achieve.. thanks -- 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: morph effects on menu roll-over.. better way?
Hey joe t., i was just coming here to reply that i solved the problem using the queue functionality of script.aculo.us. I created a separate queue for each divider and simply clear all morphs before adding a new one, so there is never the possibility of a morph finishing after its been overwritten. That is a good point regarding the CPU cycles issue (as i have noticed from time to time with testing), but for the sites purpose i am not too worried about this as there is no other real high-demand functionality involved. Thanks -- 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] morph effects on menu roll-over.. better way?
Hey, i am pretty new to prototype and script.aculo.us and have decided to develop a menu that utilizes the morph feature. It works in this manner; when a menu item is mouseover it causes 2 morphs to occur, and reverses the morph when the menu item is mouseleave. (two vertical divider bars are the elements to be morphed, located on either side of a menu item) I have got it working as i want it to so far but am having problems with flickering, and disappearing elements on either side of a menu item as every menu item shares one common divider element with the menu item beside it.. maybe i am going about coding this all wrong, but i think it should be possible to use morph in this way.. any suggestions as to how to clean it up and get rid of flickering/disappearing vertical elements so it runs smoothly? I have seen some examples of using timers, and checks for events running, but im not sure if they would apply in this situation. here is the test page: http://al-linplumbing.com/js_menutest.html the code can be viewed by viewing the page source as to not clutter up the post. if i need to explain the effect i am trying to achieve more, please let me know. Thanks, Matt -- 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] Can't seem to get AJAX form validation to work in conjunction with Codeigniter
Is there some kind of trick involved? Here's how I would envision it working: 1) User tries submitting the form 2) Event.observe captures this and sends an AJAX request to a special validation URL (PHP using Codeigniter) 3) If no errors were returned, continue submitting the original form 4) If errors were found, cancel form submission and display Mostly, I can't seem to get a separate AJAX validation request to work as the form continues submitting. I could use Event.stop(event), but have not found a way to re-start the process if no validation errors exist from the validation call. I'd post code, but I have about 15 examples of things I've tried and it would just clutter this question. Any ideas? :-( I didn't think form validation would be this difficult. Many thanks, - Matt -- 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: Can't seem to get AJAX form validation to work in conjunction with Codeigniter
Thanks. This is very helpful. What if I don't want any success text returned? This is for a search engine form. If validation passes (search criteria longer than 2 characters, etc), I just want to submit the full form and not have text returned. Should I somehow be validating against a separate URL than that which the form is being submitted to? If so, how would I do that? - Matt On Jun 16, 12:47 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, You _might_ be able to get it to work with a synchronous ajax call, but I wouldn't recommend it, the user experience would be pretty ugly. (Frozen browser for 2-3 seconds, at least.) I'd probably rejig things a bit so that validation and submission are both done at the same time, via ajax: $('yourFormId').observe('submit', function(event) { event.stop(); // Don't submit the form the normal way... this.request({ // ...and do submit it via ajax parameters: {viaAjax: true}, onSuccess: function(response) { if (response.formOkay) { // Either show success and update the page in place, or // navigate to a result page via window.location = ... } else { // Show validation errors } } }); }); Note that I added a viaAjax parameter to the form. That way, the target of the form knows whether the form was submitted via ajax or via the normal form submission mechanism. If via ajax, it validates and (if valid) updates based on the form data, and return sa JSON- formatted reply saying the form was okay (or, if not, why not). If via a normal form submission (e.g., JavaScript is disabled or something), it processes the form the old way and sends back a complete HTML page. The parameters you pass into Form#requeset[1] are merged into the form's data. Form#request will send to the URL on the form's action (unless you override it; details in the API docs). [1]http://api.prototypejs.org/dom/form/request/ HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Jun 16, 1:23 pm, Matt m...@postzero.com wrote: Is there some kind of trick involved? Here's how I would envision it working: 1) User tries submitting the form 2) Event.observe captures this and sends an AJAX request to a special validation URL (PHP using Codeigniter) 3) If no errors were returned, continue submitting the original form 4) If errors were found, cancel form submission and display Mostly, I can't seem to get a separate AJAX validation request to work as the form continues submitting. I could use Event.stop(event), but have not found a way to re-start the process if no validation errors exist from the validation call. I'd post code, but I have about 15 examples of things I've tried and it would just clutter this question. Any ideas? :-( I didn't think form validation would be this difficult. Many thanks, - Matt -- 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: Can't seem to get AJAX form validation to work in conjunction with Codeigniter
I just got this working! Here's my final JS code. While the form itself submits to /search/result/keyword as the default action, validation is an entirely different /search/validate/searchkeyword URL. script type=text/javascript Event.observe(window, 'load', function() { Event.observe('searchkeyword', 'submit', function(event) { Event.stop(event); new Ajax.Request('/search/validate/searchkeyword', { method: 'post', parameters: $('searchkeyword').serialize(true), onSuccess: function(t) { var response = t.responseText || ERROR|An error has occurred.; var responsearray = response.split('|'); if( responsearray[0] == 'ERROR' ) { document.getElementById('searchkeywordvalidate').innerHTML = responsearray[1]; } else { $('searchkeyword').submit(); } }, onFailure: function() { document.getElementById('searchkeywordvalidate').innerHTML = 'An error has occurred.'; } }); }); }); /script Thanks again. - Matt On Jun 16, 9:32 pm, Matt m...@postzero.com wrote: Thanks. This is very helpful. What if I don't want any success text returned? This is for a search engine form. If validation passes (search criteria longer than 2 characters, etc), I just want to submit the full form and not have text returned. Should I somehow be validating against a separate URL than that which the form is being submitted to? If so, how would I do that? - Matt On Jun 16, 12:47 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, You _might_ be able to get it to work with a synchronous ajax call, but I wouldn't recommend it, the user experience would be pretty ugly. (Frozen browser for 2-3 seconds, at least.) I'd probably rejig things a bit so that validation and submission are both done at the same time, via ajax: $('yourFormId').observe('submit', function(event) { event.stop(); // Don't submit the form the normal way... this.request({ // ...and do submit it via ajax parameters: {viaAjax: true}, onSuccess: function(response) { if (response.formOkay) { // Either show success and update the page in place, or // navigate to a result page via window.location = ... } else { // Show validation errors } } }); }); Note that I added a viaAjax parameter to the form. That way, the target of the form knows whether the form was submitted via ajax or via the normal form submission mechanism. If via ajax, it validates and (if valid) updates based on the form data, and return sa JSON- formatted reply saying the form was okay (or, if not, why not). If via a normal form submission (e.g., JavaScript is disabled or something), it processes the form the old way and sends back a complete HTML page. The parameters you pass into Form#requeset[1] are merged into the form's data. Form#request will send to the URL on the form's action (unless you override it; details in the API docs). [1]http://api.prototypejs.org/dom/form/request/ HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Jun 16, 1:23 pm, Matt m...@postzero.com wrote: Is there some kind of trick involved? Here's how I would envision it working: 1) User tries submitting the form 2) Event.observe captures this and sends an AJAX request to a special validation URL (PHP using Codeigniter) 3) If no errors were returned, continue submitting the original form 4) If errors were found, cancel form submission and display Mostly, I can't seem to get a separate AJAX validation request to work as the form continues submitting. I could use Event.stop(event), but have not found a way to re-start the process if no validation errors exist from the validation call. I'd post code, but I have about 15 examples of things I've tried and it would just clutter this question. Any ideas? :-( I didn't think form validation would be this difficult. Many thanks, - Matt -- 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: How would I get a closer set of siblings?
This would be an ideal use case for XPath. On Mar 5, 10:35 am, Walter Lee Davis wa...@wdstudio.com wrote: Thanks, yes that might work. But I am trying to write something which is structure-agnostic, since it goes in a plug-in for a Web design application, and I have no idea how people will want to use it. Alex's suggestion allows me to do the very least (and therefore resist the urge to screw up) while still offering an unsurprising result in a wide range of layout situations. Walter On Mar 5, 2010, at 8:08 AM, Eric wrote: Hi, All the proposed solutions are very nice example of coding, but however you may ask yourself this question: If there is no easy way to do the processing I want with my data structure, am I sure I am using the right data structure? In other words, instead of coding heavy processing functions couldn't you just change your DOM structure to optimize whatever processing you need to do with them. In your case, adding a DIV around each H3-P-P-P... sequence would do the trick. Alex: Very nice implementation! Eric On Feb 23, 6:20 pm, Walter Lee Davis wa...@wdstudio.com wrote: Wow, thanks very much Alex! Walter On Feb 23, 2010, at 11:28 AM, Alex Wallace wrote: Here's a slightly better version, as it crawls the tree itself instead of grabbing and filtering all of the element's nextSiblings(). Since it avoids the call to recursivelyCollect() it's a bit faster (with 10 siblings after the requested node, it's about 20% faster - when I upped it to about 40 elements after the node, it ran well over 250% faster). If you have a lot of nodes to filter for the accordion, I'd definitely use this version. function fasterSameTagSiblings(element) { element = $(element); var results = [], node = element.nextSibling, tag; while (node = node.nextSibling) { if (node.nodeType === 1) { tag = tag || node.tagName.toLowerCase(); if (node.tagName.toLowerCase() === tag) results.push(node) else break; } } return results; } Cheers, Alex Micro-optimization for sure, but it was bugging me. :) function fasterSameTagSiblings(element) { element = $(element); var results = [], node = element.nextSibling, tag; while (node = node.nextSibling) { if (node.nodeType === 1) { tag = tag || node.tagName.toLowerCase(); if (node.tagName.toLowerCase() === tag) results.push(node) else break; } } return results; } On Mon, Feb 22, 2010 at 8:24 PM, Walter Lee Davis wa...@wdstudio.com wrote: The heads and the paragraphs are all at the same level, and I don't want all the paragraphs, just the ones between this head and the next head. (It's for an accordion effect.) So while up('div').select('p') would do exactly what you say, it would leave me where I started. Thanks, Walter On Feb 22, 2010, at 5:46 PM, Matt Foster wrote: This is probably too obvious to be right but if you're simply looking for all of the paragraph tags at that level could you simply go up to the parent and select down from there? On Feb 22, 12:57 pm, Paul Kim kimba...@gmail.com wrote: Hi Alex, thanks for the tip. I've modified the function based on your tip and your example function: function consecutiveSameTagSiblings(element) { var element = $(element); var nextSiblings = element.nextSiblings(); var similarElements = []; similarElements.push(element); for (var i=0; i nextSiblings.length; i++) { if (element.tagName == nextSiblings[i].tagName) { similarElements.push(nextSiblings[i]); } else { break; } } return similarElements; } On Mon, Feb 22, 2010 at 9:50 AM, Alex Wallace alexmlwall...@gmail.comwrote: Paul, one recommendation: store the results of element.nextSiblings() in a local variable outside of the loop. DOM traversals are pretty slow. Best, Alex On Mon, Feb 22, 2010 at 12:28 PM, Paul Kim kimba...@gmail.com wrote: Hi Walter, if you want to get all similar elements up to but not including the next head, I would use Prototype's Element.nextSiblings() to loop through all elements with the same tagName and break when the tagName is different. Here is a function I created just now that would hopefully do what you want: function getSimilarElements(element) { var element = $(element); var similarElements = new Array(); for (var i=0; i element.nextSiblings().length; i
Re: [Proto-Scripty] Created elements work properly in Firefox, but not IE7. Why?
Maybe instead of putting onclick inside the Element constructor, use the observe method instead. confirmation_button = new Element('input', {type: 'button', value: 'Ok'}); confirmation_button.observe(click, function() {alert(button click);}); On Thu, Feb 4, 2010 at 11:23 AM, Ian ian.m.whit...@gmail.com wrote: Hello, I ran into a problem when creating some new elements. I'm sure the problem is mine, but I can't figure out the mistake I made. Hopefully someone here can point out my error. Using Prototype 1.6.0.2, I created and inserted two new elements into a page. popup_wrapper = new Element('div', { id: 'logout_warning_popup', style: 'position:relative;' confirmation_button = new Element('input', { type: 'button', value: 'Ok', onclick: window.alert('button clicked'); popup_wrapper.insert(confirmation_button); $('content').insert(popup_wrapper); Very simple. In both IE7 and Firefox (3.5.7), the box and button appeared correctly on the page. When I clicked on the Ok input in Firefox, I received the 'button clicked' alert box. But when I clicked the box in IE7, I got no alert box at all. And no indication that a js error had occurred. My first thought was that there might be a HTML syntax error that was causing the IE problem. So I copied the HTML created by the above code and made it a static part of the page. Now the button worked properly in both IE and FF. So there's something wrong in my creation of the elements that is preventing the onclick event from firing, and I'm not sure what that is. Any advice? Thanks, Ian -- 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.comprototype-scriptaculous%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en. -- Matt Milburn President, Web Developer Graphic Designer Phone: (405) 213-4353 AIM: wavemotion777 Wave Motion Studios www.wavemotionstudios.com -- 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: AsyncExecutioner
Feel free to post questions or comments here as I disabled them on the actual article. I think this is a valuable plugin for Prototype, it certainly isn't a common use case but there are instances where data gets too big to handle in one shot. On Jan 11, 9:51 am, Matt Foster mattfoste...@gmail.com wrote: Hey Everyone, I've completed work on a new Prototype plugin to handle massive datasets elegantly and avoid the dreaded Stop Script dialog. It uses a chunking algorithm to split up the dataset into small pieces, and then loop over those using chained setTimeout executions to allow a break in execution in order for regular UI processing to be handled, such as scrolling or selecting text. It can be extremely useful for less than pertinent processing that can be carried on in the background. http://positionabsolute.net/blog/2010/01/asynchronous-execution.php Regards, Matt -- 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] AsyncExecutioner
Hey Everyone, I've completed work on a new Prototype plugin to handle massive datasets elegantly and avoid the dreaded Stop Script dialog. It uses a chunking algorithm to split up the dataset into small pieces, and then loop over those using chained setTimeout executions to allow a break in execution in order for regular UI processing to be handled, such as scrolling or selecting text. It can be extremely useful for less than pertinent processing that can be carried on in the background. http://positionabsolute.net/blog/2010/01/asynchronous-execution.php Regards, Matt -- 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: self-or-ancestor in one whack?
You could use a closure to ensure you're dealing with the right element. $$('.my_table td').each(function(cell){ cell.observe('mouseover', listener.curry(cell)); }); function listener(cell, evt){ if(evt.element() != cell) return false; } Are you trying to have a clean way to avoid flickering? -- http://positionabsolute.net On Dec 19, 7:00 pm, Tobie Langel tobie.lan...@gmail.com wrote: var elm = evt.findElement('td'); is exactly the same as doing: var elm = evt.element(); if(elm.tagName.toString().toLowerCase() != 'td') elm = elm.up ('td'); Only it'll accept any kind of CSS selector. On Dec 19, 3:38 pm, Walter Lee Davis wa...@wdstudio.com wrote: I'll give that a try. I'm not sure (from the API docs) if that's going to do exactly what I want or not. Thanks, Walter On Dec 19, 2009, at 9:23 AM, ColinFine wrote: On Dec 18, 5:51 pm, Walter Lee Davis wa...@wdstudio.com wrote: I use this construction quite a lot: var elm = evt.element(); if(elm.tagName.toString().toLowerCase() != 'td') elm = elm.up('td'); whenever I am constructing a rollover listener, since it works around the whole issue with mouseover / out events firing whenever you move over a child of the element you're trying to observe. Is there a simpler way to do this, a more Prototype-y way, that is? I've had a look around the API, and I also had a Google, but the former didn't turn up anything useful and the latter turned up every commit message from every project that includes Prototype. I belive that is what Element.findElement is for. Colin -- 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 athttp://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.
[Proto-Scripty] Re: Complete graphical toolkit in js
Ext.js has a ton of UI stuff prebaked http://extjs.com -- http://positionabsolute.net On Dec 18, 4:40 am, Frédéric f...@gbiloba.org wrote: Hi, I'm wondering: does it exist a complete graphical toolkit in javascript? Something like Qt or Gtk, which allows to build complex GUI? I found several nice little projects, but they all use their own design... Thanks, -- Frédéric -- 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: Multi-dimensional JSON passed in an Ajax request?
I'd just put it in a variable. parameters : '?method=saveDatadata='+data.toJSON(); -- http://positionabsolute.net On Dec 17, 6:48 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Ajax.Updater (and the rest) don't claim to post object graphs to the server, and in fact they don't. They only pass name-value pairs, because they're doing normal HTTP GETs or POSTs, which are based on name-value pairs. HTTP doesn't know anything about JSON. If you want to pass an object graph, you could pass a single parameter with your JSON-formatted data as the value: new Ajax.Updater(this.msg, '/inc/Calendar/Validate.php', { 'parameters': {json: this.toJSON()} } ); ...and then decode the JSON-formatted data (the value of the 'json' parameter) on the server. There are JSON libraries for most server- side languages (and if there isn't one that suits your environment, well, the point of JSON is that it is easily parsed -- see json.org for details). HTH, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Dec 17, 10:14 pm, Ian R i...@fairmountfair.com wrote: So ok, I have this JSON string I'm trying to pass as a post. From my object's toJSON() method, I get this string: { anonymous_element_1: { class: required, msg: }, anonymous_element_2: { class: required, msg: }, public_phone: { class: phone, value: 706-201-1149, msg: }, private_phone: { class: phone, value: 315-487-9176, msg: } } Which is valid JSON according tohttp://www.jsonlint.com/... However, when I try to pass this to a PHP script: new Ajax.Updater(this.msg, '/inc/Calendar/Validate.php', { 'parameters': this.toJSON() } ); I get nothing passed. However, I've noticed that if I take the multidimensional aspect out of it and just use the format {'key':'value,'key':'value'}, it passes just fine. Also, if I specifically set the method to get, I this passed in $_GET Array ( [{anonymous_element_1:_ {class:_required,_msg:_},_anonymous_element_2:_ {class:_required,_msg:_},_public_phone:_ {class:_phone,_value:_706-201-1149,_msg:_},_private_phone:_ {class:_phone,_value:_315-487-9176,_msg:_}}] = ) Basically a crazy URL-encoded version of my JSON, as the key in a valueless array. Hm. What am I doing wrong here? I just don't get it. Thanks in advance! Ian -- 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: Sychronize many asynchronous Ajax.Request
I'd recommend taking a look at my Ajax Service Queue approach, such that all requests go through the service object, and in the subclass for the queue's case won't send the next request until its predecessor has returned. It needs to be updated for 1.6 but the idea is on the wall for you to look at... Most pertinently is the onFinish event which would work perfectly for your circumstance. http://positionabsolute.net/blog/2007/04/ajax-request-queue.php On Nov 24, 8:30 am, Alex McAuley webmas...@thecarmarketplace.com wrote: Yes... Objects and thier properties are built and stored in memory (how else would they get built) - the CPU does the calculations and outputs the opcode to the browser (which reads from memory) what it needs to do with the object (In very simple terms)... So it stands to reason that if you dont remove the Object from memory it will just add to the memory bracket. To test... Build a test page with a periodical ajax request and (on winblows) watch the RAM that for instance firefox uses in the task manager go up and up and up. Then close the whole browser (so it starts clean again) and assign the periodical updater to a variable var request=new Ajax.Periodical...({}); request=null; And watch the difference between what happend in the first test and the second... In the second test the browser frees up 60-80% of the memory that it used to make/process the request by nulling the object back to a null byte If you look on TJ's proto scripty wikidot my results are there and the code that accompanies it. I assumed it was common knowledge that people garbage collected ajax requests... Its not just prototypejs but every ajax style library that does not garbage collect these requests Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: david david.brill...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, November 24, 2009 11:54 AM Subject: [Proto-Scripty] Re: Sychronize many asynchronous Ajax.Request Yes your right Alex, but the case of maalek did not mention such numbers of request. I think in his case using one array is better than using a lot (~14 differents variables). btw, I'm interrest in In fact the actal request stays in memory unless you null the object and after reflexion, that is logical, but is it normal ?? -- david On 24 nov, 09:37, Alex McAuley webmas...@thecarmarketplace.com wrote: Arrays are stored in memory, they are not a cookie so they do not get stored on the client machine .. (and you yourself say that even if it was its not cross browser) To test .. Do 100 requests with large responses and save them all into an array and see how much memory the web browser is eating each time you do one... In fact the actal request stays in memory unless you null the object - i wrote a post on this in TJ's proto scripty wiki which has test cases to prove it. I dont see any reason ever to save the response of multiple requests in an object that is saved in memory of the client's browser what happens if they are on an iPhone or somehting with not alot of memory ? Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: david david.brill...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Tuesday, November 24, 2009 7:24 AM Subject: [Proto-Scripty] Re: Sychronize many asynchronous Ajax.Request I'm sorry Alex, but I definitely not agree with you ! First because there is existing method to cache the Ajax request and they use local object to save the result (we have now some new way to save locally a variable but it's not cross-browser). And next, because an array is much more flexible than variables. you could access each element independantly and have the length method (In our exemple, to know how much elements have been saved). And if each request should have a specific position in the array, length is no more working, but Prototype have sugaristic method that help you playing with Array the way you need. But there is I think plenty way to do this. -- david On 23 nov, 23:44, Alex McAuley webmas...@thecarmarketplace.com wrote: It would polute the variable and seriously eat RAM to save every result response in an array, i would highly recommend staying away from it.. Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: david david.brill...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, November 23, 2009 8:00 PM Subject: [Proto-Scripty] Re: Sychronize many asynchronous Ajax.Request Hi all, if you need to save all returned value, just save each request result in an array. Check the length of the result list to know when all request are finished. But we still turn around the same
[Proto-Scripty] Re: Stopping an enumeration
I'd like to use enumeration functions to select from a sorted list where I know that if the select function has passed and then starts failing (returns false) This isn't a prime situation for Enumerable but certainly nothing it can't handle. Never mind - I just discovered $break in the docs Really, what documentation covered the $break variable? I've always considered this as Prototype property and although you can get away with it in most cases, I'd strongly advise against manipulating that variable yourself. I'm not sure what use case you're going for, are you collecting the items in the array that match or just getting to the max index of matches and then exiting? Here is some quick and dirty code of how to work out a situation like yours with Enumerable methods... var vocab = [ apples, apricot, airplane, bass, banana, bounce, card, carry, cart, ceasar ]; var myFlag = false; var myRegex = /^b.*/; var myFilter = function(val, itr){ if(val.search(myRegex) -1 myFlag == false){ myFlag = true; } else if(val.search(myRegex) == -1 myFlag == true){ myFlag = false; } return (myFlag val.search(myRegex) -1); } var newVocab = vocab.collect(myFilter); console.log(newVocab); On Nov 9, 6:47 am, andy.kri...@gmail.com andy.kri...@gmail.com wrote: Never mind - I just discovered $break in the docs - that should do what I want. On Nov 9, 6:41 am, andy.kri...@gmail.com andy.kri...@gmail.com wrote: I'd like to use enumeration functions to select from a sorted list where I know that if the select function has passed and then starts failing (returns false), I can stop enumerating (because every additional item will also fail). For example, scanning a sorted array of strings for strings that start with a regexp - once the regexp has found matches and then stops matching again, there's no need to continue. Is that possible with the built-in functions or should I be looping over the array myself in this case? --~--~-~--~~~---~--~~ 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: Effect.Morph to enlarge images
You could use a fisheye... http://positionabsolute.net/blog/2007/08/prototype-fisheye.php On Nov 3, 12:55 pm, ph...@ryangibbons.net ph...@ryangibbons.net wrote: Richard, Thanks for the response. Question though, I am not quit sure what you mean. I would like the image the enlarge upon mouse over and go back original size on mouse out...hopefully as a smooth transition. I have seen some very heavy JS scripts that do this but I was looking for a lighter alternative using script.aculo.us Thanks, RG On Nov 3, 9:45 am, Richard Quadling rquadl...@googlemail.com wrote: 2009/11/3 ph...@ryangibbons.net ph...@ryangibbons.net: Hey all, I was trying to come up with a simple way to enlarge images on mouse over and set them back to their normal size on mouse out. I figured why not try Effect.Morph with two sets of css for the images. Implementation can be seen here: http://rgvisuals.com/ie/(Clickon Stories link) Problem I am running into is that it seems to be quite jittery. I know that this is doable in Flash but I am just not much of a Flash fan. I am taking it by my simple exploration that Effect.Morph may not be the most stable or correct ways of going about this. Can anyone point me in the right direction? Thanks, Ryan I think you have to know if you are scaling an image and if so, not perform any other scaling on that image. -- - Richard Quadling Standing on the shoulders of some very clever giants! EE :http://www.experts-exchange.com/M_248814.html Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 ZOPA :http://uk.zopa.com/member/RQuadling --~--~-~--~~~---~--~~ 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: Insert , Defer and Is there a better way?
Hey Kiran, Function.defer is simply delegating the functions execution to Function.delay which in the end delegates it to a wrapper of window.setTimeout. By using defer it enforces the timeout to be a value of 0.01 which is just enough to hiccup the browser's procedural processing. If your application relies on this element to be inserted, avoid the defer and you'll be sure the content is loaded after execution of insert. -- http://positionabsolute.net On Nov 2, 7:41 pm, phegaro pheg...@gmail.com wrote: HI T.J, I'm sorry but are you asking for more than what is above? I can write a simple page that puts together the HTML and JS listed above. Is that what you want? Kiran On Oct 30, 2:22 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Kiran, It sounds like you've already put together a minimalist test case, would you post it (e.g., to Pastie[1] or similar)? I haven't run into a situation where a single defer wasn't sufficient, but I also haven't tested extensively on Mac OS. Cheers, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Oct 30, 7:19 am, phegaro pheg...@gmail.com wrote: Hi all, This might be a more generic browser/javascript questions than a prototype specific quesiton but i thought it would better to ask here because you all tend to really understand javascript and browsers in a ton of detail. So here goes. If i execute the following code: HTML: div id=area/div Javascript: $('area').insert({bottom: div id=inserted/div}); var count = 0; var f = function() { if ($('inserted') == null) { console.log(not there); count++; if (count 50) { $('area'.insert({bottom: div id=inserted/ div}); count = 0; } f.defer(); } else { console.log(there); } }; f(); Result: Most of the time it just shows: there but some of the time it does this not there not there not there there I am assuming because the insert is something that is queued and the browser then inserts the nodes into the DOM in its next event loop. I know that webkit is a single threaded so this makes sense that sometimes its not there and then it gets there, so really i guess i have to wait till its there before i can do the next thing on that inserted node. What about firefox and IE? Are they all single threaded in the same way? What happens in Chrome? Sometimes i see the following happen also which is really concerning to me: not there not there ... 50 times not there there It happens every so often on webkit (mac os) and on iPhone webkit and i can reproduce it pretty easily. I have built something simple that will do this but all this seems a little crazy to me because when i look at others code they dont even take this into account. They never way for DOM elements to show up when inserting HTML text into a DOM element. Any answers/suggestions would be super helpful. Kiran --~--~-~--~~~---~--~~ 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: Insert , Defer and Is there a better way?
In taking a second look at your code... Are you using the F function recursively to wait for the DOM to be loaded and your area element to be available? you can use many other approaches... Prototype $(document).observe(dom:loaded, function()...); Traditional window.onload = function()... By executing your code in those methods, you can be sure that DOM elements are loaded and ready for manipulation via Javascript. -- http://positionabsolute.net On Nov 5, 3:22 pm, Matt Foster mattfoste...@gmail.com wrote: Hey Kiran, Function.defer is simply delegating the functions execution to Function.delay which in the end delegates it to a wrapper of window.setTimeout. By using defer it enforces the timeout to be a value of 0.01 which is just enough to hiccup the browser's procedural processing. If your application relies on this element to be inserted, avoid the defer and you'll be sure the content is loaded after execution of insert. -- http://positionabsolute.net On Nov 2, 7:41 pm, phegaro pheg...@gmail.com wrote: HI T.J, I'm sorry but are you asking for more than what is above? I can write a simple page that puts together the HTML and JS listed above. Is that what you want? Kiran On Oct 30, 2:22 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Kiran, It sounds like you've already put together a minimalist test case, would you post it (e.g., to Pastie[1] or similar)? I haven't run into a situation where a single defer wasn't sufficient, but I also haven't tested extensively on Mac OS. Cheers, -- T.J. Crowder Independent Software Consultant tj / crowder software / comwww.crowdersoftware.com On Oct 30, 7:19 am, phegaro pheg...@gmail.com wrote: Hi all, This might be a more generic browser/javascript questions than a prototype specific quesiton but i thought it would better to ask here because you all tend to really understand javascript and browsers in a ton of detail. So here goes. If i execute the following code: HTML: div id=area/div Javascript: $('area').insert({bottom: div id=inserted/div}); var count = 0; var f = function() { if ($('inserted') == null) { console.log(not there); count++; if (count 50) { $('area'.insert({bottom: div id=inserted/ div}); count = 0; } f.defer(); } else { console.log(there); } }; f(); Result: Most of the time it just shows: there but some of the time it does this not there not there not there there I am assuming because the insert is something that is queued and the browser then inserts the nodes into the DOM in its next event loop. I know that webkit is a single threaded so this makes sense that sometimes its not there and then it gets there, so really i guess i have to wait till its there before i can do the next thing on that inserted node. What about firefox and IE? Are they all single threaded in the same way? What happens in Chrome? Sometimes i see the following happen also which is really concerning to me: not there not there ... 50 times not there there It happens every so often on webkit (mac os) and on iPhone webkit and i can reproduce it pretty easily. I have built something simple that will do this but all this seems a little crazy to me because when i look at others code they dont even take this into account. They never way for DOM elements to show up when inserting HTML text into a DOM element. Any answers/suggestions would be super helpful. Kiran --~--~-~--~~~---~--~~ 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] Prototype gadget for client side translation
Hey Everyone, I've put the finishing touches on a JS based gadget to handle site translation. It uses Prototype for class structure and element collection etc and the Google Translate API to handle the actual text translations. It handles all of the requests async style and never reloads the page. Nor does it destructively handle node collection, so all of your event handlers remain intact... Check it out http://positionabsolute.net/blog/2009/10/google-translate-gadget-site-translation.php Cheers, Matt --~--~-~--~~~---~--~~ 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] onComplete functions firing after HTTP/1.1 connection closed
I'm trying to use Prototype to do some basic Ajaxy things for the first time in ages, and have run into a problem that I've seen reported before, but with no replies: http://groups.google.com/group/prototype-scriptaculous/browse_thread/thread/152b95c89f7d7dc5/1478a6d7456c4df8?lnk=gstq=oncomplete#1478a6d7456c4df8 I have a function like this to send an async request back to the server (in my case Ruby+Rack+Sinatra, and I'm testing with Firefox 3.5 and whatever the current Linux Chrome build is): function toggleAcknowledge(id) { updater = new Ajax.Request('/alert/'+id+'/acknowledge', { method:'post', onSuccess: function(response) { alert(Success); }, onComplete: function(response) { alert(Complete); } }); }; I've found that when the Updater method is set to 'post', the onSuccess and onComplete functions fire after 30 seconds, rather than when the request has completed (which is pretty much instantly). This obviously means updates won't happen to my page etc. It seems that the 30 second delay corresponds to the HTTP/1.1 connection being closed; while the connection is open but the request complete, the callbacks don't fire. If I change the method to 'get' I don't see this problem. Would appreciate some prototype veterans' ideas on how to fix / work around it - my first instinct was to ask the browser to use HTTP/1.0 but I assume this is a bit too low-level - any better ideas on how to handle it? Thanks, -- Matthew --~--~-~--~~~---~--~~ 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: onChange in Dynamic Element not working in IE6
This one was a SOB and as always, IE is at fault... Here is what I found on researching this... now this is for IE only of course.. var cell = new Element(td); This is all well and good w/o any attributes, the Element constructor delegates the attributes object, the second parameter to Element.writeAttribute... cell.writeAttribute(class, text); fails to work due to the attribute translations, found in the Element._attributeTranslations.write object. IE8 is now expecting to write to the literal class attribute, not the className that it gets translated to. cell.setAttribute(class, text); //this works fine in IE8 cell.addClassName(text); //this also works but its not using element attributes but the JS DOM reference itself, ie cell.className = ... -- http://positionabsolute.net On Oct 26, 4:04 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Just as a side measure that you are probably not aware of... IE8 has a bug that when you do your new Element(td..,'class':'text'... It will not add the class to IE8 browsers ... you need to use addClassName('text'); after you insert it... I found this out the hard way ! Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: molo maurice_lowent...@ssga.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, October 26, 2009 7:27 PM Subject: [Proto-Scripty] onChange in Dynamic Element not working in IE6 The following code works in Firefox but the onChange/onBlur events do not get triggered from the browser in IE6 Does anyone know 1) How to fix this 2) If I should use a different approach for dynamically building the form elements I dynamically build elements on the screen base on a button being entered to call a function var newSecurityTdInput = new Element('td' , {'class':'text'}); var newSecurityInput = new Element('input', {'type':'text', 'class':'text newid', 'name':'newid', 'onChange': validateNewSecurityChange(this); ,'onBlur': getSecurityName (this);}); newSecurityTdInput.appendChild(newSecurityInput); newSecurityTr.appendChild(newSecurityTdInput); Thanks --~--~-~--~~~---~--~~ 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: Depreciation of Array#reduce
What is ES5? On Oct 23, 1:31 pm, Tobie Langel tobie.lan...@gmail.com wrote: We removed it because it conflicted with an identically named method specified in ES5. If you really need to use it, I strongly sugest you find another name for it. Best, Tobie --~--~-~--~~~---~--~~ 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: Tying an Element and a custom class together
Yeah that'd be great functionality to allow for a much simpler proxy On Oct 19, 9:48 am, Eric lefauv...@gmail.com wrote: Matt, I like your way of doing it, but my concern is that the documented toElement() method seems to be only half implemented. A minor change to the $() function could make it work completely (see it here:http://pastie.org/660553). What do you guys think about this change? Eric On Oct 17, 12:11 am, Matt Foster mattfoste...@gmail.com wrote: Quick and dirty, im sure there are errors but conceptually this would be my approach... var ElementProxy = Class.create({ initialize : function(ele){ this.element = $(ele); this.nodeType = this.element.nodeType; this.tagName = this.element.tagName; this.delegateMethods(); }, delegateMethods : function(){ var methods = Element.Methods; for(var method in methods){ var __method = methods[method]; if (Object.isFunction(__method) !(__method in this)) this.assignMethod(method, __method); } }, assignMethod : function(method, __method){ this[method] = function(){ return __method.apply(this.element, [this.element].concat($A(arguments))); }; } }); -- http://positionabsolute.net On Oct 16, 3:01 pm, Matt Foster mattfoste...@gmail.com wrote: The has a relationship is the only way to go for sure. You could create an ElementProxy class that inherits all the Element methods but just keeps a reference to the actual DOM reference internally. All of the Element.Methods are parameterized so I'm sure there'd be an easy way to delegate the reference. As long as the ElementProxy class implements all the regular methods then core prototype processes wouldn't know the difference between the two. -- http://positionabsolute.net On Oct 16, 12:02 pm, Eric lefauv...@gmail.com wrote: Hi, While I agree with T.J. arguments, there are cases when it is nice to have this behavior (DOM element and Plain object in the same object). On of those case is, for example when you're creating a new control class. The way I do it is: - building the DOM element in the class's constructor (and keeping it in an attribute) (*) - implement the toElement() method in the class (to return this DOM element) (*) The second step allows you to provide your class instance to any prototype method instead of a DOM element. A small example:http://jsbin.com/omaza Ops: Previous sentence was wrong... After trying to write the example, and checking in the source, it seems that you can only use this kind of object as a DOM element in a handfull of prototype's methods (insert, update and replace)... Is it any reason why this behavior is not implemented in $() (this would actually allow to use a custom class everywhere where a DOM element is needed, and just add one line of code). Eric (*) This was the simplest way to explain the process, but you may prefer dynamically create the DOM element on the first call of toElement() for better efficiency. On Sep 10, 10:56 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Andrea, FWIW, I'd say the best practice is: Don't do that, it conflates the model with the view *and* the controller. :-) (MVC is not by any means the only game in town, but the terminology is useful for questions like this.) If you ever want to present the business object in two different ways in two different panels (in a list, for instance, and in a details pane that shows the details of the highlighted object in the list), you can't, or rather the code gets ugly fast. Instead, I'd suggest keeping the business object separate from the element and using a has a rather than an is a relationship. You can do that by storing the business object ID on the element in some way (data-key is the attribute I usually use for this, and fits with the proposed HTML5 data attributes standard), either directly or via a small controller. The business object should never update the element directly, and so it doesn't need to know about it. Instead, it should raise events that controllers can respond to by updating the elements they control. When I say fire event, I'm not necessarily talking browserspeak (I wouldn't use browser events for this), just a minimal
[Proto-Scripty] Re: Tying an Element and a custom class together
The has a relationship is the only way to go for sure. You could create an ElementProxy class that inherits all the Element methods but just keeps a reference to the actual DOM reference internally. All of the Element.Methods are parameterized so I'm sure there'd be an easy way to delegate the reference. As long as the ElementProxy class implements all the regular methods then core prototype processes wouldn't know the difference between the two. -- http://positionabsolute.net On Oct 16, 12:02 pm, Eric lefauv...@gmail.com wrote: Hi, While I agree with T.J. arguments, there are cases when it is nice to have this behavior (DOM element and Plain object in the same object). On of those case is, for example when you're creating a new control class. The way I do it is: - building the DOM element in the class's constructor (and keeping it in an attribute) (*) - implement the toElement() method in the class (to return this DOM element) (*) The second step allows you to provide your class instance to any prototype method instead of a DOM element. A small example:http://jsbin.com/omaza Ops: Previous sentence was wrong... After trying to write the example, and checking in the source, it seems that you can only use this kind of object as a DOM element in a handfull of prototype's methods (insert, update and replace)... Is it any reason why this behavior is not implemented in $() (this would actually allow to use a custom class everywhere where a DOM element is needed, and just add one line of code). Eric (*) This was the simplest way to explain the process, but you may prefer dynamically create the DOM element on the first call of toElement() for better efficiency. On Sep 10, 10:56 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Andrea, FWIW, I'd say the best practice is: Don't do that, it conflates the model with the view *and* the controller. :-) (MVC is not by any means the only game in town, but the terminology is useful for questions like this.) If you ever want to present the business object in two different ways in two different panels (in a list, for instance, and in a details pane that shows the details of the highlighted object in the list), you can't, or rather the code gets ugly fast. Instead, I'd suggest keeping the business object separate from the element and using a has a rather than an is a relationship. You can do that by storing the business object ID on the element in some way (data-key is the attribute I usually use for this, and fits with the proposed HTML5 data attributes standard), either directly or via a small controller. The business object should never update the element directly, and so it doesn't need to know about it. Instead, it should raise events that controllers can respond to by updating the elements they control. When I say fire event, I'm not necessarily talking browserspeak (I wouldn't use browser events for this), just a minimal implementation of the Observer pattern (as a mixin or similar you can use for lots of different objects). FWIW, and apologies if I went OT, but I hope I didn't, -- T.J. Crowder tj / crowder software / comwww.crowdersoftware.com On Sep 9, 3:02 pm, Andrea Campi andrea.ca...@gmail.com wrote: Hi, in my application I need JS objects to represent some business objects, which are represented on the page by an Element. I would like to be able to tie the two together in such a way that I can use them interchangeably. This sounds like it should be a common pattern, so I was wondering what the best practices are. Example: var Foo = Class.create({ initialize: function(parent) { var element = Object.extend(new Element(div, { 'class': 'foo', 'id': 'myFoo' }), this); parent.insert(element); }, bar: function() { } // more methods }; Thanks to Object.extend I can easily call: $('myFoo').bar() But I cannot do the opposite, for instance: var foo = new Foo(); foo.childElements(); Note that it would just work if I could return 'element' (which now behaves like Foo). However, I've readhttp://dev.rubyonrails.org/ticket/11481andithas reasonable objections to letting the constructor return a value. So, what gives? Any suggestion? TIA, Andrea --~--~-~--~~~---~--~~ 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: Tying an Element and a custom class together
Quick and dirty, im sure there are errors but conceptually this would be my approach... var ElementProxy = Class.create({ initialize : function(ele){ this.element = $(ele); this.nodeType = this.element.nodeType; this.tagName = this.element.tagName; this.delegateMethods(); }, delegateMethods : function(){ var methods = Element.Methods; for(var method in methods){ var __method = methods[method]; if (Object.isFunction(__method) !(__method in this)) this.assignMethod(method, __method); } }, assignMethod : function(method, __method){ this[method] = function(){ return __method.apply(this.element, [this.element].concat($A(arguments))); }; } }); -- http://positionabsolute.net On Oct 16, 3:01 pm, Matt Foster mattfoste...@gmail.com wrote: The has a relationship is the only way to go for sure. You could create an ElementProxy class that inherits all the Element methods but just keeps a reference to the actual DOM reference internally. All of the Element.Methods are parameterized so I'm sure there'd be an easy way to delegate the reference. As long as the ElementProxy class implements all the regular methods then core prototype processes wouldn't know the difference between the two. -- http://positionabsolute.net On Oct 16, 12:02 pm, Eric lefauv...@gmail.com wrote: Hi, While I agree with T.J. arguments, there are cases when it is nice to have this behavior (DOM element and Plain object in the same object). On of those case is, for example when you're creating a new control class. The way I do it is: - building the DOM element in the class's constructor (and keeping it in an attribute) (*) - implement the toElement() method in the class (to return this DOM element) (*) The second step allows you to provide your class instance to any prototype method instead of a DOM element. A small example:http://jsbin.com/omaza Ops: Previous sentence was wrong... After trying to write the example, and checking in the source, it seems that you can only use this kind of object as a DOM element in a handfull of prototype's methods (insert, update and replace)... Is it any reason why this behavior is not implemented in $() (this would actually allow to use a custom class everywhere where a DOM element is needed, and just add one line of code). Eric (*) This was the simplest way to explain the process, but you may prefer dynamically create the DOM element on the first call of toElement() for better efficiency. On Sep 10, 10:56 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi Andrea, FWIW, I'd say the best practice is: Don't do that, it conflates the model with the view *and* the controller. :-) (MVC is not by any means the only game in town, but the terminology is useful for questions like this.) If you ever want to present the business object in two different ways in two different panels (in a list, for instance, and in a details pane that shows the details of the highlighted object in the list), you can't, or rather the code gets ugly fast. Instead, I'd suggest keeping the business object separate from the element and using a has a rather than an is a relationship. You can do that by storing the business object ID on the element in some way (data-key is the attribute I usually use for this, and fits with the proposed HTML5 data attributes standard), either directly or via a small controller. The business object should never update the element directly, and so it doesn't need to know about it. Instead, it should raise events that controllers can respond to by updating the elements they control. When I say fire event, I'm not necessarily talking browserspeak (I wouldn't use browser events for this), just a minimal implementation of the Observer pattern (as a mixin or similar you can use for lots of different objects). FWIW, and apologies if I went OT, but I hope I didn't, -- T.J. Crowder tj / crowder software / comwww.crowdersoftware.com On Sep 9, 3:02 pm, Andrea Campi andrea.ca...@gmail.com wrote: Hi, in my application I need JS objects to represent some business objects, which are represented on the page by an Element. I would like to be able to tie the two together in such a way that I can use them interchangeably. This sounds like it should be a common pattern, so I was wondering what
[Proto-Scripty] Re: how to select all elements by class after a certain point?
var nextElements=$(element).descendants();// returns everythign that This would return all children of the element, not siblings. On Oct 10, 4:26 am, Alex McAuley webmas...@thecarmarketplace.com wrote: If you use Event with element you can find the element that was clicked $$('.blah').each(function(e) { $(e).observe('click',function(event){ var element=Event.element(event); // this is the element var nextElements=$(element).descendants();// returns everythign that is a }); }); This is untested. Your list is a straight list of divs so it may not work - but try it and see!.. HTH Alex Mcauley http://www.thevacancymarket.com - Original Message - From: patrick patrick99...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Saturday, October 10, 2009 8:41 AM Subject: [Proto-Scripty] how to select all elements by class after a certain point? Hi everyone, I am a bit stuck on this.. So, I have a layout with something like this: div class=blahblah/div div class=blahblah/div div class=other_class/div div class=blahblah/div div class=blahblah/div div class=blahblah/div div class=other_class/div div class=blahblah/div ... I have a function that is called when one of my '.blah' divs is clicked, and so in that function 'this' refers the particular div.. I am trying to figure out how I can get all of the divs that are '.blah' after 'this'... Thank you. -patrick --~--~-~--~~~---~--~~ 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: Submit form on select for autosuggest
You've defined your function after you reference it... It needs to be created first then it can be referenced. function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); -- http://positionabsolute.net On Oct 8, 10:45 pm, Yogesh Agashe yogesh.aga...@gmail.com wrote: Hello, Thanks for the reply. I tried doing that but it didn't work for me.If you point out the mistake in following code, it will be great.Thanks again.script type=text/javascript new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } /scriptThanks, Yogesh Matt Foster wrote:http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleterafterUpdateElement function... you receive an input object and some element that was representing the field. At this point you could execute form.submit.. --http://positionabsolute.netOn Oct 7, 11:19 am, Yogeshyogesh.aga...@gmail.comwrote:Hello, I am using Ajax.autocompleter in one of my forms. I am calling a custom function getSelectedId after update element to get an ID of the selected list item. I need a functionality such that form should get submitted whenever : 1) a user clicks a item using mouse from the autosuggest list. 2) Whenever user presses enter key while a list item is selected. (This I have achieved through a hack as shown in code below. I call .submit() after getSelectedId function) I don't know how to submit the form on mouse click. Any help on this issue will be really helpful to me. script type=text/javascript new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } /script Thank you. Sincerely, Yogesh --~--~-~--~~~---~--~~ 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: how to select all elements by class after a certain point?
Hence the note on it This might not work as its divs. The name of the elements have no weight on the issue. The structure of the elements are all that matters. Siblings != Children You should have added the disclaimer... This does not work... On Oct 12, 3:04 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Hence the note on it This might not work as its divs. Alex Mcauley http://www.thevacancymarket.com - Original Message - From: Matt Foster mattfoste...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, October 12, 2009 7:12 PM Subject: [Proto-Scripty] Re: how to select all elements by class after a certain point? var nextElements=$(element).descendants();// returns everythign that This would return all children of the element, not siblings. On Oct 10, 4:26 am, Alex McAuley webmas...@thecarmarketplace.com wrote: If you use Event with element you can find the element that was clicked $$('.blah').each(function(e) { $(e).observe('click',function(event){ var element=Event.element(event); // this is the element var nextElements=$(element).descendants();// returns everythign that is a }); }); This is untested. Your list is a straight list of divs so it may not work - but try it and see!.. HTH Alex Mcauley http://www.thevacancymarket.com - Original Message - From: patrick patrick99...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Saturday, October 10, 2009 8:41 AM Subject: [Proto-Scripty] how to select all elements by class after a certain point? Hi everyone, I am a bit stuck on this.. So, I have a layout with something like this: div class=blahblah/div div class=blahblah/div div class=other_class/div div class=blahblah/div div class=blahblah/div div class=blahblah/div div class=other_class/div div class=blahblah/div ... I have a function that is called when one of my '.blah' divs is clicked, and so in that function 'this' refers the particular div.. I am trying to figure out how I can get all of the divs that are '.blah' after 'this'... Thank you. -patrick --~--~-~--~~~---~--~~ 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: Submit form on select for autosuggest
Hey Yogesh, You may want to also look at how you're referencing the form. Usually document.forms is a numerical array, not an associative. I'd recommend using an ID on the form object and then grab it via $(form_id)... document.forms['searchcustomerform'].submit(); vs $(searchcustomerform).submit(); Cheers, Matt On Oct 12, 3:02 pm, Yogesh Agashe yogesh.aga...@gmail.com wrote: Hello, I am glad to say that I found the root of the problem. I had a button named submit and this was causing the problem. Thanks so much Matt for pointing out the function definition error. As Christo notes here: (http://www.spiration.co.uk/post/1232/Submit%20is%20not%20a%20function) This means you have a function trying to call the form's submit() method, but you also have a button which is called submit(). This causes a conflict in javascript, because the submit method is already bound to that button. To solve the problem, simply change the name of the button so that name=moo (or something). Your submit() call in your javascript function/method will now work. Sincerely, Yogesh Yogesh Agashe wrote:Thanks for pointing out this error Matt. I should have noticed this. But even after defining the function earlier, form submit doesn't work :( Sorry. Sincerely, Yogesh Matt Foster wrote:You've defined your function after you reference it... It needs to be created first then it can be referenced. function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); --http://positionabsolute.netOn Oct 8, 10:45 pm, Yogesh Agasheyogesh.aga...@gmail.comwrote:Hello, Thanks for the reply. I tried doing that but it didn't work for me.If you point out the mistake in following code, it will be great.Thanks again.script type=text/javascript new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } /scriptThanks, Yogesh Matt Foster wrote:http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleterafterUpdateElementfunction... you receive an input object and some element that was representing the field. At this point you could execute form.submit.. --http://positionabsolute.netOn Oct 7, 11:19 am, Yogeshyogesh.aga...@gmail.comwrote:Hello, I am using Ajax.autocompleter in one of my forms. I am calling a custom function getSelectedId after update element to get an ID of the selected list item. I need a functionality such that form should get submitted whenever : 1) a user clicks a item using mouse from the autosuggest list. 2) Whenever user presses enter key while a list item is selected. (This I have achieved through a hack as shown in code below. I call .submit() after getSele ctedId function) I don't know how to submit the form on mouse click. Any help on this issue will be really helpful to me. script type=text/javascript new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } /script Thank you. Sincerely, Yogesh --~--~-~--~~~---~--~~ 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: How to fire a custom/synthetic Control key + mouse scroll wheel movement event?
Hey Alex, You failed to see his point. You failed to see mine Ctrl + mouse wheel scales the page not the text - it scales images, elements, text and everything If said images and elements widths and font-size properties were given using the em unit, they'd be scaled just the same. LOL glad to see you think your own misperceptions are so comical. Implement the pastie to see how my example works before you jump to these grand slanderous conclusions. -- http://positionabsolute.net On Oct 8, 2:32 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: You failed to see his point. Ctrl + mouse wheel scales the page not the text - it scales images, elements, text and everything LOL Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: Matt Foster mattfoste...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Thursday, October 08, 2009 6:58 PM Subject: [Proto-Scripty] Re: How to fire a custom/synthetic Control key + mouse scroll wheel movement event? So just as a recap, you're looking to simulate the ctrl + mouse wheel event such that the native processing for zoom magnification applies? This is a highly useful feature, I would love to add some widgets type icons (magnifier glasses with a + and -) on my site that allows people to rescale the document image using it. It would very intuitive (just click the +magnifier icon to make it bigger and visa versa). So really you want a control on your page that increases font size? My approach would be to design everything I want to be scalable using the em unit so that everything is relative. Set a modest em level at the body level such that everything else is relative to this value. Then the control simply modifies the value for this to propagate the zoom in/out effect. http://pastie.org/647201 -- http://positionabsolute.net On Oct 8, 12:16 pm, tcupolo tcup...@afsincorporated.biz wrote: @Radoslav, I took some time today to look through your patch. It would make this function very easy to implement. It would take the form of a keypress event with ctrlkey=true and the necessary keyCode and charCode values. What is it's status? Will it make it into a future version of Prototype anytime soon? If not, what is the recommended way of using a patch like this? (I assume including it as a seperate js file on each page override the original function definition of fire, but that's not completely clear.) It took a little time for me to realize but I think it's the best way to go for a cross-browser compatible ZOOM solution. Thanks for the reply. On Oct 1, 7:47 am, Radoslav Stankov rstan...@gmail.com wrote: A time ago I have created ticket and a patch for making Event.fire to fire event (https://prototype.lighthouseapp.com/projects/8886/tickets/697-eventfi... ) Here is a git forhttp://gist.github.com/121011 I hope it's useful --~--~-~--~~~---~--~~ 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: How to fire a custom/synthetic Control key + mouse scroll wheel movement event?
So just as a recap, you're looking to simulate the ctrl + mouse wheel event such that the native processing for zoom magnification applies? This is a highly useful feature, I would love to add some widgets type icons (magnifier glasses with a + and -) on my site that allows people to rescale the document image using it. It would very intuitive (just click the +magnifier icon to make it bigger and visa versa). So really you want a control on your page that increases font size? My approach would be to design everything I want to be scalable using the em unit so that everything is relative. Set a modest em level at the body level such that everything else is relative to this value. Then the control simply modifies the value for this to propagate the zoom in/out effect. http://pastie.org/647201 -- http://positionabsolute.net On Oct 8, 12:16 pm, tcupolo tcup...@afsincorporated.biz wrote: @Radoslav, I took some time today to look through your patch. It would make this function very easy to implement. It would take the form of a keypress event with ctrlkey=true and the necessary keyCode and charCode values. What is it's status? Will it make it into a future version of Prototype anytime soon? If not, what is the recommended way of using a patch like this? (I assume including it as a seperate js file on each page override the original function definition of fire, but that's not completely clear.) It took a little time for me to realize but I think it's the best way to go for a cross-browser compatible ZOOM solution. Thanks for the reply. On Oct 1, 7:47 am, Radoslav Stankov rstan...@gmail.com wrote: A time ago I have created ticket and a patch for making Event.fire to fire event (https://prototype.lighthouseapp.com/projects/8886/tickets/697-eventfi... ) Here is a git forhttp://gist.github.com/121011 I hope it's useful --~--~-~--~~~---~--~~ 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: Event#observe on elements
Yeah don't worry about it. Your use case works fine, its the way IE handles event observers that has the memory leak. Other browsers its fine and as noted, prototype handles this IE anomaly under the covers for you so you're good. On Oct 6, 1:57 pm, Ngan Pham nganp...@gmail.com wrote: Thanks for the reply. I do understand that Just because an element has been detached from the visible DOM doesn't mean that the reference can be maintained elsewhere. I just assumed that once it is detached, and the object isn't referenced anywhere else in the code that it would be collected by garbage collection, just like any other variable: function test() { var i = 0; var j = $('some-element').remove(); } it's my thinking that after test() has finished running, that both i and j would be picked up by garbage collection. is this not true? So, what you're saying, to answer my question, is that I don't have to worry about using Event#stopObserving? On Tue, Oct 6, 2009 at 10:22 AM, Matt Foster mattfoste...@gmail.com wrote: The removed element? Just because an element has been detached from the visible DOM doesn't mean that the reference can be maintained elsewhere. It would be no edge case to detach and re-attach a particular element, so to think that an element should be trashed just because it has no parent node is a bad perception. Prototype has accomodations for IE's poor garbage collection tactics and has a cleanup method for this that gets handled transparently to you. -- http://positionabsolute.net On Oct 6, 12:05 pm, Ngan Pham nganp...@gmail.com wrote: Hey everyone, I have a quick question. If put some Event#observe on an element...and then later remove the element with Element#remove, do I have to do Event#stopObserving? Or do the event detach themselves once garbage collection picks up the removed element? Thanks! --~--~-~--~~~---~--~~ 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: Submit form on select for autosuggest
http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleter afterUpdateElement function... you receive an input object and some element that was representing the field. At this point you could execute form.submit.. -- http://positionabsolute.net On Oct 7, 11:19 am, Yogesh yogesh.aga...@gmail.com wrote: Hello, I am using Ajax.autocompleter in one of my forms. I am calling a custom function getSelectedId after update element to get an ID of the selected list item. I need a functionality such that form should get submitted whenever : 1) a user clicks a item using mouse from the autosuggest list. 2) Whenever user presses enter key while a list item is selected. (This I have achieved through a hack as shown in code below. I call .submit() after getSelectedId function) I don't know how to submit the form on mouse click. Any help on this issue will be really helpful to me. script type=text/javascript new Ajax.Autocompleter(search,hint,server_class.php, {afterUpdateElement : getSelectedId, minChars:1}); function getSelectedId(text, li) { $('class_id').value=li.id; document.forms['searchcustomerform'].submit(); } /script Thank you. Sincerely, Yogesh --~--~-~--~~~---~--~~ 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: Variabalized containment
http://prototypejs.org On Oct 6, 7:45 am, WLQ maybe...@gmail.com wrote: Sounds plausible, I would like to have more information on that please. On 5 Okt., 08:14, Alex McAuley webmas...@thecarmarketplace.com wrote: Why not give your list a class name thats specific to the list and select with $$ Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: WLQ maybe...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Sunday, October 04, 2009 3:05 PM Subject: [Proto-Scripty] Variabalized containment The question is, how can I tell containment to include all lists with Id's of someid_somenumber. Somenumber being any number, let's say I've got 20 lists with the Id of someid_{ID}. So I don't really know the full ID of the list. I want to be able to receive items from the lists id of which includes someid_ regardless of what number goes after. Thanks, Yan- Skjul tekst i anførselstegn - - Vis tekst i anførselstegn - --~--~-~--~~~---~--~~ 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: Event#observe on elements
The removed element? Just because an element has been detached from the visible DOM doesn't mean that the reference can be maintained elsewhere. It would be no edge case to detach and re-attach a particular element, so to think that an element should be trashed just because it has no parent node is a bad perception. Prototype has accomodations for IE's poor garbage collection tactics and has a cleanup method for this that gets handled transparently to you. -- http://positionabsolute.net On Oct 6, 12:05 pm, Ngan Pham nganp...@gmail.com wrote: Hey everyone, I have a quick question. If put some Event#observe on an element...and then later remove the element with Element#remove, do I have to do Event#stopObserving? Or do the event detach themselves once garbage collection picks up the removed element? Thanks! --~--~-~--~~~---~--~~ 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: Range utility increment
I hadn't thought of that and a good point. So if you create a NumberRange of even numbers from 2 to 6 and ask it if 3 is included, unless you override that behavior in your NumberRange class, `include` will return true. The range object itself will certainly return true in this scenario. as it does fall within the beginning and end. Although in most cases, and certainly in my example I've wrapped the instance within an Enumerable ($A) which also has an include method (actually ObjectRange inherits and overrides this method).. but the Enumerable.include method is..quoting the API docs based on the == comparison operator (equality with implicit type conversion) such that, 3 is simply not a number created by the range, hence not a value in the enumerable. http://api.prototypejs.org/language/enumerable.html#include-instance_method -- http://positionabsolute.net On Sep 28, 7:27 pm, T.J. Crowder t...@crowdersoftware.com wrote: Matt, The ObjectRange `include` method looks like this: function include(value) { if (value this.start) return false; if (this.exclusive) return value this.end; return value = this.end; } So if you create a NumberRange of even numbers from 2 to 6 and ask it if 3 is included, unless you override that behavior in your NumberRange class, `include` will return true. -- T.J. On Sep 28, 9:20 pm, Matt Foster mattfoste...@gmail.com wrote: Hey TJ, I don't understand, if a NumberRange was given an instance of EvenNumber as its start and end parameters, how would it come up with the number 3? On Sep 26, 7:10 am, T.J. Crowder t...@crowdersoftware.com wrote: All right, lads, let's move along... Each approach has its benefits and costs, it all depends on what problem you're solving. Matt, FWIW, I think you'd want to override the `include` method as well, as others a NumberRange with even numbers would include 3. At that point you're overriding most of ObjectRange, so I'd probably just start from Enumerable. This is not intended as a dig. -- T.J. On Sep 25, 9:51 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: Omg get over yourself you have taken what i said completely the wrong way.. What arrogant plug was that?... Lets take your code and look at it shall we... 30+ lines for no reason other than Hey look at me, i can write a function/class in 30 lines that only needs to be 5. Chill out dude, i wasn't knocking your code, it was just OTT. You can continue to think you are right which is arrogance in itself... there is more than one way to skin a cat. TJ's/My loop that took all of 30 seconds to create is faster no doubt, has less weight and does the job. I personaly have better things to do than write some amazing class to achieve what can be done in 30 seconds - evidently you do not so good luck with that. Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: Matt Foster mattfoste...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, September 25, 2009 9:16 PM Subject: [Proto-Scripty] Re: Range utility increment That only gives you even or odd increments to the top number... Incorrect, notice the constructor method? It ensures that the number given is even such that you'll never get a range of odd numbers. Granted the last line of the Jojo's question was Let's say count up by 2's: [2,4,6,8,10]. How do you do this? Hence why I went with this specific implementation, to demonstrate how you can create classes that the ObjectRange class can use to create proper ranges. I didn't feel it was necessary to abstract out the class such that it covers all bases but demonstrate how to do it one way and then Jojo could modify for their own purposes. Better to go with my/TJ's loop What an arrogant plug of your own spaghetti code and hasty discredit to my contribution. Exposing your shortfalls isn't difficult, you aren't creating a range object, completely bypassing the ObjectRange's functionality and just simply creating a hacked out array. So to put the nail in the coffin, here is the classes abstracted out var IncrementNumber = Class.create({ initialize : function(num, increment){ this.num = num; this.increment = increment;}, succ : function(){ return this.clone(this.num + this.increment, this.increment);}, clone : function(num, increment){ return new IncrementNumber(num, increment);}, toString : function(){ return this.num;} }); var EvenNumber = Class.create(IncrementNumber, { initialize : function($super, num){ $super(num, 2); this.num = (num % 2 == 1) ? num - 1 : num;}, clone : function(num, increment){ return new EvenNumber(num);} }); var NumberRange = Class.create
[Proto-Scripty] Re: Range utility increment
I'd just use an 'iterator' class to do this... var EvenNumber = Class.create( { initialize : function(num){ this.num = (num % 2 == 1) ? num - 1 : num; }, succ : function(){ return new EvenNumber(this.num + 2); }, toString : function(){ return this.num; } }); var bottom = new EvenNumber(1); var top = new EvenNumber(21); var range = $A($R(bottom, top)); console.log(range); I had done this to a much greater extent in my date range selector gadget. Where it became the master range, held a range of calendar objects, which were in themselves ranges of date objects... fun stuff. https://positionabsolute.net/blog/2008/01/google-calendar-date-range-selection.php ps just looking over that, should rename that class to PositiveEvenNumber, only going to work one way, but you get the idea On Sep 25, 4:15 am, Alex McAuley webmas...@thecarmarketplace.com wrote: function everyOther(start, end, increment) { var n; var rv = []; for (n = start; n = end; n += increment) { rv[rv.length] = n; } return rv; } Just a mod to make it better to be able to change it to 3's, 4's, 5's ;) Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: T.J. Crowder t...@crowdersoftware.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, September 25, 2009 8:29 AM Subject: [Proto-Scripty] Re: Range utility increment Hi, I'm looking for a way to specify that I want to increment by any value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this? ObjectRange itself is for ranges of consecutive values, but you can get an array of such values by applying Enumerable#collect to a range: var twos; twos = $R(1, 5).collect(function(x) { return x * 2; }); ...although frankly I'd probably go with a straight loop like Alex did (although a slightly different one): function everyOther(start, end) { var n; var rv = []; for (n = start; n = end; n += 2) { rv[rv.length] = n; } return rv; } FWIW, -- T.J. Crowder tj / crowder software / comwww.crowdersoftware.com On Sep 24, 11:15 pm, JoJo tokyot...@gmail.com wrote: http://www.prototypejs.org/api/utility/dollar-r From the documentation of the Range utility, it seems like it can only increment by 1's. For example, $A($R(1,10,true)) gives you: [1,2,3,4,5,6,7,8,9,10]. I'm looking for a way to specify that I want to increment by any value. Let's say count up by 2's: [2,4,6,8,10]. How do you do 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] Re: Range utility increment
That only gives you even or odd increments to the top number... Incorrect, notice the constructor method? It ensures that the number given is even such that you'll never get a range of odd numbers. Granted the last line of the Jojo's question was Let's say count up by 2's: [2,4,6,8,10]. How do you do this? Hence why I went with this specific implementation, to demonstrate how you can create classes that the ObjectRange class can use to create proper ranges. I didn't feel it was necessary to abstract out the class such that it covers all bases but demonstrate how to do it one way and then Jojo could modify for their own purposes. Better to go with my/TJ's loop What an arrogant plug of your own spaghetti code and hasty discredit to my contribution. Exposing your shortfalls isn't difficult, you aren't creating a range object, completely bypassing the ObjectRange's functionality and just simply creating a hacked out array. So to put the nail in the coffin, here is the classes abstracted out var IncrementNumber = Class.create({ initialize : function(num, increment){ this.num = num; this.increment = increment; }, succ : function(){ return this.clone(this.num + this.increment, this.increment); }, clone : function(num, increment){ return new IncrementNumber(num, increment); }, toString : function(){ return this.num; } }); var EvenNumber = Class.create(IncrementNumber, { initialize : function($super, num){ $super(num, 2); this.num = (num % 2 == 1) ? num - 1 : num; }, clone : function(num, increment){ return new EvenNumber(num); } }); var NumberRange = Class.create(ObjectRange, { _each: function(iterator) { var value = this.start; while (this.include(value.num)) { iterator(value.num); value = value.succ(); } }, }); var bottom = new IncrementNumber(-10, 2); //var bottom = new EvenNumber(-20); var top = new EvenNumber(25); var range = $A(new NumberRange(bottom, top)); console.log(range); nothing gets me fired up like a flame... On Sep 25, 2:25 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: That only gives you even or odd increments to the top number... WHat if you wanted every 5th number ... Better to go with my/TJ's loop Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: Matt Foster mattfoste...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, September 25, 2009 5:57 PM Subject: [Proto-Scripty] Re: Range utility increment I'd just use an 'iterator' class to do this... var EvenNumber = Class.create( { initialize : function(num){ this.num = (num % 2 == 1) ? num - 1 : num; }, succ : function(){ return new EvenNumber(this.num + 2); }, toString : function(){ return this.num; } }); var bottom = new EvenNumber(1); var top = new EvenNumber(21); var range = $A($R(bottom, top)); console.log(range); I had done this to a much greater extent in my date range selector gadget. Where it became the master range, held a range of calendar objects, which were in themselves ranges of date objects... fun stuff. https://positionabsolute.net/blog/2008/01/google-calendar-date-range-... ps just looking over that, should rename that class to PositiveEvenNumber, only going to work one way, but you get the idea On Sep 25, 4:15 am, Alex McAuley webmas...@thecarmarketplace.com wrote: function everyOther(start, end, increment) { var n; var rv = []; for (n = start; n = end; n += increment) { rv[rv.length] = n; } return rv; } Just a mod to make it better to be able to change it to 3's, 4's, 5's ;) Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: T.J. Crowder t...@crowdersoftware.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, September 25, 2009 8:29 AM Subject: [Proto-Scripty] Re: Range utility increment Hi, I'm looking for a way to specify that I want to increment by any value. Let's say count up by 2's: [2,4,6,8,10]. How do you do this? ObjectRange itself is for ranges of consecutive values, but you can get an array of such values by applying Enumerable#collect to a range: var twos; twos = $R(1, 5).collect(function(x) { return x * 2; }); ...although frankly I'd probably go with a straight loop like Alex did (although a slightly different one): function everyOther(start, end) { var n; var rv = []; for (n = start; n = end; n += 2) { rv
[Proto-Scripty] Prototype ajax history
Hey Everyone, I've finished a project that handles the problems of browser history when implementing ajax solutions. It's built to integrate with prototype perfectly and borrows a lot of the same concepts. The idea is an event driven system where all XHRs go through a single 'service' object which deals with server communications. This way we can register each request with the browser's history module and be able to accommodate the user as he/she traverses the history array. Take a look when you have a minute, its surely worth the time. http://positionabsolute.net/blog/2009/09/ajax-history-wars.php#number=6 --~--~-~--~~~---~--~~ 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: Prototype ajax history
You asked for it Mona, I've set you up as a contributor for the project http://code.google.com/p/agileajax/ On Sep 21, 1:39 pm, Mona Remlawi mona.reml...@gmail.com wrote: thanks for sharing this! i would love to contribute to this project if any help is needed .. let me know cheers -- mona On Mon, Sep 21, 2009 at 7:00 PM, Matt Foster mattfoste...@gmail.com wrote: Hey Everyone, I've finished a project that handles the problems of browser history when implementing ajax solutions. It's built to integrate with prototype perfectly and borrows a lot of the same concepts. The idea is an event driven system where all XHRs go through a single 'service' object which deals with server communications. This way we can register each request with the browser's history module and be able to accommodate the user as he/she traverses the history array. Take a look when you have a minute, its surely worth the time. http://positionabsolute.net/blog/2009/09/ajax-history-wars.php#number=6 --~--~-~--~~~---~--~~ 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] Scriptaculous onmouseover
So I'm creating a light-weight expanding and collapsing menu. I am using the morph property to expand and contract the height of the list items in the menu onmouseover. I am running into issues however where (once I've expanded the list) every time I rollover an item within the expanded list item, it re-triggers the morph effect. Basically I'm just wondering if there is a quick and easy way for scriptaculous effects to work well onmouseover and onmouseout. Thanks! --~--~-~--~~~---~--~~ 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: Element#Storage
I agree with Jim, If I remove an element from the DOM for whatever reason, perhaps its a control widget that only gets inserted for inline editing or something. I don't want to re-apply listeners and proprietary data each time I reinsert the control back into the document. And this leads to another point that was made in another discussion about deep cloning, So lets say we implement the functionality to Element.remove and when you invoke this, it takes all the steps to properly dispose of that element, fantastic, but what about child elements, does it also walk through all children/grand children to detect and remove storage data for these as well? -- http://positionabsolute.net On Sep 9, 3:44 pm, david david.brill...@gmail.com wrote: Hi Jim, I could have both opinion: - As it is attach on an element what is the interrest of having data staying inline and element disapear ? - But as you say, if you want to keep data when the element is removed from the DOM, because we know that it will be recreate. When reading the prototype blog post {1], one purpose of this class is used to avoid memory leak in IE, which seems to go in the direction of removing data. In the post, there is a link to $.fn.data and there, nothing is said in API documentation of this function. I think that this type of question is for should ask to our team athttp://groups.google.fr/group/prototype-core [1]http://prototypejs.org/2009/2/16/pimp-my-code-1-element-storage -- david On 9 sep, 16:26, Jim Higson j...@wikizzle.org wrote: On Tuesday 08 September 2009 12:09:38 david wrote: Hi Yaffle, There is nothing in the code that seems to automatically delete the Storage object when an element is deleted. Even in the Element .remove, But removing an element doesn't mean I'll never use it again. I might remove it from the document and add it in somewhere else and I wouldn't want the data associated with it to have gone in the meantime. -- Jim my wiki ajaxification thing:http://wikizzle.org my blog:http://jimhigson.blogspot.com/ --~--~-~--~~~---~--~~ 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: More useful clone method
Scenario for you... What if I have a parent object that I use deepClone on and it has child elements that have event handlers, is this functionality preserved with the method? On Aug 26, 1:18 pm, watermark86 watermar...@gmail.com wrote: Well, I have x-mas presents. I give it it works for me status. I've tested this bit of code with firefox and it seems to work with every scenario I can throw at it. I'm sure there is room for speed improvements and I know it doesn't conform to coding style, but it works. It would be great if prototype officially extended Element.clone with this functionality. deepClone: function(element) { var newElement = element.clone(true); //clone the node //stop observing all events on the newElement (IE (and some others?) copies them) newElement.stopObserving(); //copy storage Element.getStorage(newElement); (Element.Storage[newElement._prototypeUID[0]]=new Hash (Element.getStorage(element))).unset('prototype_event_registry'); //copy the events on the parent if (!Object.isUndefined(registry = Element.retrieve(element, 'prototype_event_registry'))) { registry.each( function(pair) { var eventName = pair.key, responders = pair.value; responders.each( function(r) { Element.observe(newElement, eventName, r.handler); }); }); } //get all of the descendants var srcdecend = element.descendants(); var dstdecend = newElement.descendants(); var numdecend = srcdecend.length; //foreach of the descendants for(var i = 0; i numdecend; ++i) { //stop observing all events on the newElement (IE (and some others?) copies them) dstdecend[i].stopObserving(); //copy storage Element.getStorage(dstdecend[i]); (Element.Storage[dstdecend[i]._prototypeUID[0]]=Element.getStorage (srcdecend[i]).clone()).unset('prototype_event_registry'); //copy the events on each child to it's new corrisponding child var registry = Element.retrieve(srcdecend[i], 'prototype_event_registry'); if (!Object.isUndefined(registry)) { registry.each( function(pair) { var eventName = pair.key, responders = pair.value; responders.each( function(r) { Element.observe(dstdecend[i], eventName, r.handler); }); }); } } return newElement; } On Aug 26, 9:43 am, watermark86 watermar...@gmail.com wrote: 1.6.1rc3 added Element.clone (which calls cloneNode). On Aug 25, 5:46 pm, Matt Foster mattfoste...@gmail.com wrote: Good luck with this, let us know if it works out. Quick glance at your code I can see an obvious error... var newElement = element.clone(true); //clone the node Element doesn't have a clone method. The native DOM element does have a cloneNode method though. -- http://positionabsolute.net On Aug 25, 2:15 pm, watermark86 watermar...@gmail.com wrote: I'm using 1.6.1rc3 to have access to Element.storage. I need to write a function that deep clones an element and copies the Element.observe events as well as the Element.Storage items with it. I've managed to write the code that can copy one or the other. The problem comes in when I try to do both (copy the storage items and the events.) I suppose due to Event.observe using the Element.storage item, I can't seem to have the items that I've stored with Element.store to copy while maintaining the Event.observe events that I've copied. I can copy the observe events or the element.store events, but not both. Below is some terrible code for review. Thanks for any help or insults. deepClone: function(element) { //deep clone node var newElement = element.clone(true); //clone the node //stop observing because of IE BS newElement.stopObserving(); //copy the item var registry = Element.retrieve(element, 'prototype_event_registry'); if (!Object.isUndefined(registry)) { registry.each( function(pair) { var eventName = pair.key, responders = pair.value; responders.each( function(r) { Element.observe(newElement, eventName, r.handler); }); }); } //for all of the descendants, copy the event handlers var srcdecend = element.descendants(); var dstdecend = newElement.descendants(); var numdecend = srcdecend.length
[Proto-Scripty] Re: KEY_DOWN event
The down arrow. Perhaps the preceding key up, key left and key right options could have given you a clue... On Aug 25, 8:07 am, Ooypunk ooyp...@gmail.com wrote: OK, then I'll go with that. Thanks! Only thing left for me to complain is that I still don't know what names like KEY_DOWN are for, or how they should be used, and that there's nothing in the manual (hint). On Aug 25, 11:37 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, If you want to know whether the control key was down when the mouse was clicked, then yes, the ctrlKey property of the mouse click event object is what you want. element.observe('click', function(event) { if (event.ctrlKey) { // Something cool here } } https://developer.mozilla.org/en/DOM/event.ctrlKey If you're looking to receive an event (separate from the click) when the control key is pressed, that varies quite a bit by browser:http://unixpapa.com/js/key.html But my impression is that you're just looking for it when the mouse is clicked, which is much more reliable. HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 25, 12:09 am, Ooypunk ooyp...@gmail.com wrote: Hi, I was looking for a way to capture a mouse-click plus ctrl-button. As I am using Prototype now for some time (it's great!), I thought Prototype could help me with this too. Sure, the manual is clear enough of how to capture a mouse-click event (that works fine here), but how about the ctrl-button? According to the manual, there's a list of key codes to be used (KEY_DOWN, for example), but there is no KEY_CTRL and there is nowhere to be found how they should be used. It says it's self explanatory, but for me it isn't. :( I think I can get it to work with event.ctrlKey, but I have a feeling, this is not the way. Thanks in advance. Ooypunk PS. I hope I made my problem clear enough, I know I'm not very good at explaining, especially because english is not my mother tongue. --~--~-~--~~~---~--~~ 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: More useful clone method
Good luck with this, let us know if it works out. Quick glance at your code I can see an obvious error... var newElement = element.clone(true); //clone the node Element doesn't have a clone method. The native DOM element does have a cloneNode method though. -- http://positionabsolute.net On Aug 25, 2:15 pm, watermark86 watermar...@gmail.com wrote: I'm using 1.6.1rc3 to have access to Element.storage. I need to write a function that deep clones an element and copies the Element.observe events as well as the Element.Storage items with it. I've managed to write the code that can copy one or the other. The problem comes in when I try to do both (copy the storage items and the events.) I suppose due to Event.observe using the Element.storage item, I can't seem to have the items that I've stored with Element.store to copy while maintaining the Event.observe events that I've copied. I can copy the observe events or the element.store events, but not both. Below is some terrible code for review. Thanks for any help or insults. deepClone: function(element) { //deep clone node var newElement = element.clone(true); //clone the node //stop observing because of IE BS newElement.stopObserving(); //copy the item var registry = Element.retrieve(element, 'prototype_event_registry'); if (!Object.isUndefined(registry)) { registry.each( function(pair) { var eventName = pair.key, responders = pair.value; responders.each( function(r) { Element.observe(newElement, eventName, r.handler); }); }); } //for all of the descendants, copy the event handlers var srcdecend = element.descendants(); var dstdecend = newElement.descendants(); var numdecend = srcdecend.length; for(var i = 0; i numdecend; ++i) { //stop observing because of IE BS dstdecend[i].stopObserving(); //copy the registry var registry = Element.retrieve(srcdecend[i], 'prototype_event_registry'); if (!Object.isUndefined(registry)) { registry.each( function(pair) { var eventName = pair.key, responders = pair.value; responders.each( function(r) { Element.observe(dstdecend[i], eventName, r.handler); }); }); } } return newElement; } --~--~-~--~~~---~--~~ 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: Reuse 'Effect' code for looping
http://prototypejs.org/api/function/delay var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; var delayConstant = 1; arr.each(function(value, index){ (function(val){ $(myInput).value = val; }).delay(delayConstant * index, value); }); -- http://positionabsolute.net On Aug 14, 5:53 am, Benj ben...@gmail.com wrote: Hey, I want to create a new effect that changes a numerical value in a text input box from one value to another by cycling through each number inbetween the two values. i.e. if the original value is 199.99 and I want to update it to 259.99 (normally with ajax) I would like the input value to be changed as below: 199.99 209.99 219.99 229.99 239.99 249.99 259.99 This should create a sped-up digital clock effect. I will play about with which numbers to include depending on the distance between the values. How do I harness the looping used for core effects to perform this operation? This will also provide me with the transitions and timing. Thanks --~--~-~--~~~---~--~~ 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: Casting a json object into an instance of a class
You could just have the server return code that instantiates the object to begin with. You aren't limited to JSON its just convienent because the structure is simple and there are plenty of processors that understand it. But you can evaluate any JS code just as is. -- http://positionabsolute.net On Aug 12, 8:36 am, T.J. Crowder t...@crowdersoftware.com wrote: At least, I now know what is the state of the art way of getting a class instance through Ajax ;o) Well, I don't know if it's state of the art, but provided you're in control of both ends (so, for instance, the raw data object doesn't get fields that end up overwriting your methods), it seems fine. Thanks again! Happy to help, -- T.J. On Aug 12, 12:06 pm, Eric lefauv...@gmail.com wrote: Thanks for your reply T.J.! I did used Class instead of class. This was a typo when I posted :o) You're right, it should have work the way I did it... and it actually did work this way... ...except that due to a mistake in my events handling, my new thing value was overridden by some obsolete part of code just after being converted into a class instance :o( And since it was overridden by the raw JSON object value, I stupidly assumed that the casting didn't work. At least, I now know what is the state of the art way of getting a class instance through Ajax ;o) Thanks again! Eric On Aug 12, 10:49 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, That should work. I notice that you have class.Create rather than Class.create; I assume that's just an error in the note and that the actual code uses Class.create? Because if not, that's your problem. if(myInstance.isB())... = isB is undefined That indicates there's a different problem. isB should be defined regardless, you defined it in your class definition. If the Object.extend thing weren't working, it should *return* undefined, but not *be* undefined. FWIW, this works: * * * * (also athttp://pastie.org/581050) // Defining var Thing = Class.create({ initialize: function(src) { if (src) { Object.extend(this, src); } }, isB: function() { return this.b; } }); // Using: var t; t = new Thing({b: true}); alert(t.isB() ? + t.isB()); * * * * HTH, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available --~--~-~--~~~---~--~~ 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: image flickering with Effect.Morph
I am trying to code an OS X-style menu bar with prototype Are you talking about the dock? http://positionabsolute.net/blog/2007/08/prototype-fisheye.php On Jul 13, 4:05 pm, Mario Colombo mario.colo...@yetnet.ch wrote: Hi everybody, I am trying to code an OS X-style menu bar with prototype and scriptaculous 1.8.2. I have two problems which I hope to solve with your feedback. I myself am stuck after failing with all the ideas I had. Please find the example here:http://aldebaran.mine.nu/menu/menu.htmlhttp://aldebaran.mine.nu/menu/menu.jshttp://aldebaran.mine.nu/menu/menu.css 1st problem: image flickering: changing mouseover over the different divs produces a flash or flickering. Reading this group and other sources suggest that it is a problem with different Effects active at the same time. I tried to solve this over Effect.Queues and cancel the whole queue with my scope: 'menu' but unfortunately cancelling queues results in no effects at all: ---[code]-- // menuelement is the current menu div from $$('.level_one').each (function(menuelement) { elDimensions = menuelement.getDimensions(); // to set style manually to where the effect was cancelled var queue = Effect.Queues.get('menu'); // cancelling the whole scope: 'menu' queue queue.each(function(effect) { effect.cancel(); }); menuelement.setStyle('height:'+ elDimensions.height + 'px; ' + 'width:' + elDimensions.width + 'px;') // set dimensions to where effect stops var myEffect = new Effect.Morph(menuelement, {style: {width:'100px', height:'100px'}, queue: {position: 'end', scope: 'menu'}}); //new effect takes place ---[/code]-- I also tried to save all effects to the same variable myEffect, trying to have them overwrite themselves, which brought a partial improvement. 2nd problem: On 'mouseout' I would like the menu to return to its original state 'width:100px; height:100px;' I tried the following code: ---[code]-- Event.observe($('menu'), 'mouseout', function(event) { // 'menu' is the id of the containing div $$('.level_one').each(function(menuelement) { var myEffect = new Effect.Morph(menuelement, {style: {width:'100px', height:'100px'}}); });}); ---[/code]-- This resulted in erratic behaviour. Help would be greatly appreciated. Help for better OO programming is always welcome. Thank you in advance. Mario --~--~-~--~~~---~--~~ 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 keys from a JSON object returned from transport.responseText.evalJSON(); or for that matter any JSON object
var keys = $H(obj).keys(); http://prototypejs.org/api/hash/keys -- http://positionabsolute.net On Aug 10, 10:46 am, Alex McAuley webmas...@thecarmarketplace.com wrote: You can prolly sort the order if you wanted it in some kind of order but its not needed in my opinion! Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: T.J. Crowder t...@crowdersoftware.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Monday, August 10, 2009 3:37 PM Subject: [Proto-Scripty] Re: Getting keys from a JSON object returned from transport.responseText.evalJSON(); or for that matter any JSON object Hi, Regardless of where the object came from (having evaluated it from a JSON string or something else), that's what for..in is for: var name, obj = {'a': 1, 'b': 2}.evalJSON(); for (name in obj) { alert(name + = + obj[name]); } ...alerts a=1 then b=2. The order is not guaranteed. Cool, eh? Speaking generally, for..in iterates through the names of the properties in the object. Note that depending on the object in question, some of those properties may refer to functions: var obj = { foo: function() { alert(Foo!); }, bar: 42 }; var name; for (name in obj) { alert(typeof obj[ + name + ] = + typeof obj[name]); } ...alerts obj[foo] = function and obj[bar] = number. for..in includes properties an object has inherited from its prototype: var a = ['one', 'two']; var name; for (name in a) { alert(typeof a[ + name + ] = + typeof a[name]); } ...will not only alert a[0] =one and a[1] = 2 but also any other enumerable properties on arrays. In most implementations, there aren't any other *enumerable* properties (some properties can be marked dontEnum, but only by the implementation, not our code), but when you're using Prototype, there are lots -- because Prototype adds lots of properties to the Array prototype referencing additional nifty Array functions. Which is why you don't use for..in to loop through array elements, there could be more than just the array elements.[1] You can filter out the properties that are inherited from the prototype by using hasOwnProperty: var a = ['one', 'two']; var name; for (name in a) { if (a.hasOwnProperty(name)) { alert(typeof a[ + name + ] = + typeof a[name]); } } ...will only alert the two you expect. All of the above is JavaScript, not Prototype; details in the spec[2]. [1]http://proto-scripty.wikidot.com/prototype:tip-looping-through-arrays [2]http://www.ecma-international.org/publications/standards/Ecma-262.htm HTH, have fun! -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Aug 10, 2:54 pm, krishna81m krishna...@gmail.com wrote: I tried to google and search prototype API for a method that will give me just the keys in a JSON object. Is there none in Prototype and no way to know the keys? Regards Krishna --~--~-~--~~~---~--~~ 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: autosuggest feature enter button hack in new Ajax.Autocompleter
I've never actually used this component but in researching the docs, could you use the callback for afterUpdateElement and then programatically execute the form's submit method? http://wiki.github.com/madrobby/scriptaculous/ajax-autocompleter -- http://positionabsolute.net On Aug 7, 10:11 am, Yogesh yogesh.aga...@gmail.com wrote: Hello All, I have just joined this group and it's my first post. I will like to thank the community for coming up with such a powerful library. I am using new Ajax.Autocompleter in one of script and it works fine. I am using it in a input text box, in which, user types in the search term and back end script queries the database to get a result set and suggested items get shown as a list in input text box. When the suggested items show up as list in my input text box, when I press enter/tab key, a single list item gets selected. However, to submit this item, I have to press enter key again. In short, I need to hit enter twice in order to submit the list item. I will like if this action is done in a single hit of enter key. I tried using some JavaScript hacks to submit the form on enter key but I think scriptaculus is over riding it. Is this the case? Is there any way to make this work with just single enter key? Thanks. Regards, Yogesh --~--~-~--~~~---~--~~ 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: Class with Ajax and onclick event
Depending on when you wanted to pass the additional argument you could just attach it to the argument chain on bind this.changeContent = this.changeContent.bindAsEventListener(this, extraArgument); Since we're already looking at that line of code, be careful, reassigning the function to a bound version of itself could get tricky if you decide to create a subclass of Dynamic. -- http://positionabsolute.net On Aug 4, 9:24 am, Liviu Timar mailti...@gmail.com wrote: Hello, This is my first post here. Thus, I'll like to say hello to everybody in this community and I want to appologize if this question was asked before. I am a web developer for a site that has 1mil+ visitors/month: www [dot] ziare [dot] ro, and I want to use the Prototype Framework to make an element refresh itself (with an scriptaculous Effect) periodically. This is my class: var Dynamic = Class.create({ initialize: function(selector, container, script) { this.selector = selector; this.script = script; this.container = container; this.changeContent = this.changeContent.bindAsEventListener(this); this.getContent(); }, getContent: function() { new Ajax.Request(this.script, { onSuccess: function(req) { this.content = req.responseJSON; //document.fire('content:retrieved', req.responseJSON); } }); $$(this.selector).invoke('observe', 'click', this.changeContent.bind (this)); }, changeContent: function(event) { event.preventDefault(); console.log(this.content); console.log(this.container); /*new Effect.Fade($(this.container), { afterFinish: function() { new Effect.Appear($(this.container)); } }); $(this.container).update('cucu');*/ }}); document.observe('dom:loaded', function() { var dyn = new Dynamic(.tzNavLink a, tzContent, titlurileZilei.php); }); 'tzContent' is the div whose content changes by clicking on of the links with the 'tzNavLink' css class (the 1 2 3 4 5 6 links onwww.ziare.ro). The problem is that this.content is undefined in changeContent (a function that listens for the click event), although this.container works well in the same function. Why is that? It has something to do with the Ajax.Request? Also, I want to ask how can I 'tzContent' to change periodically using such and object (I want everything to be encapsulated so I can use this object in other projects)? Thank you for your response. --~--~-~--~~~---~--~~ 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: Class.create and this keyword
In an effort to keep the code clean I'd delegate this functionality to a dedicated method other than the constructor. On Aug 4, 2:16 pm, Matt Foster mattfoste...@gmail.com wrote: If you really wanted to avoid bind you could just use closures within the initialize method var Sub4 = Class.create(Super4, { baz: bat, initialize: function () { var self = this; var f = function () { alert(Class:+self.fu+self.baz); }; document.observe(click,f); } }); On Aug 4, 3:35 am, Cédric bertolini.ced...@gmail.com wrote: On 3 août, 22:38, Matt Foster mattfoste...@gmail.com wrote: Regardless of the JS framework. A closure is necessary for attaching class methods to a particular instance and preserve the instance reference via the this keyword. This is automatic with the regular Constructor syntax. Defining a function as an object method inside a constructor creates a closure, so we can use #bind at the same time as the definition. The point is, Class.create acts like a prototype more than as a constructor. I never really thought of that. So I can't bind to my object instance inside Class.create. And I guess that what acts as a constructor in Class is the initialize method... So, maybe, I should define f inside initialize, something like: var Sub4 = Class.create(Super4, { baz: bat, initialize: function () { this.f = function () { alert(Class:+this.fu+this.baz); }.bind(this); document.observe(click, this.f); } }); Is there a cost to operating that way? I guess I won't be able to use Class.addMethods... I thought Function.bind was pretty clean myself, but I guess you've got the sweet tooth for the syntax. I think #bind is awesome :) It's the bind the function in the initializer that bothers me, when I compare it to the standard syntax bind the function at its definition. --~--~-~--~~~---~--~~ 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: Masked Input in Prototype
The plugin's code is compliant with not conflicting with the $ function. But in your implementation of this plugin, you'll have to be sure to use jQuery(#maskInput).mask(...); instead of the demo's example code which uses the $ method. -- http://positionabsolute.net On Jul 30, 9:23 am, Celso cels...@gmail.com wrote: Unfortunately I am no expert in prototype. I can not believe that someone has developed a prototype mask! I try to use prototype and jquery together, Works:http://docs.jquery.com/Using_jQuery_with_Other_Libraries But .. the plugin does not works. On 29 jul, 18:27, Alex McAuley webmas...@thecarmarketplace.com wrote: why not just port the jquery one... wont take long ! Alex Mcauleyhttp://www.thevacancymarket.com - Original Message - From: Celso cels...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Wednesday, July 29, 2009 10:22 PM Subject: [Proto-Scripty] Re: Masked Input in Prototype something like this:http://digitalbush.com/projects/masked-input-plugin On 24 jul, 06:48, Richard Quadling rquadl...@googlemail.com wrote: 2009/7/23 Matt Foster mattfoste...@gmail.com: You must further define your idea of masked input http://www.google.com/search?q=define%3A+masked+inputie=utf-8oe=utf... On Jul 23, 3:58 pm, Celso cels...@gmail.com wrote: Anyone know a masked input in prototype? Thanks, Celso. An inputmask[1] is where you can say enter text in a form like ... AA nn nn nn A You would be able to type 2 letters, 6 numbers and then 1 letter. The case would be forced to upper case and the spacing would be automatic. BO 52 91 91 V for example OR Are you talking about hiding the input? Like input type=password ? Regards, Richard. [1]http://www.google.co.uk/search?q=define:+input+mask -- - Richard Quadling Zend Certified Engineer :http://zend.com/zce.php?c=ZEND002498r=213474731 Standing on the shoulders of some very clever giants! ZOPA :http://uk.zopa.com/member/RQuadling --~--~-~--~~~---~--~~ 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: Class.create and this keyword
Regardless of the JS framework. A closure is necessary for attaching class methods to a particular instance and preserve the instance reference via the this keyword. http://www.javascriptkit.com/javatutors/closures.shtml I thought Function.bind was pretty clean myself, but I guess you've got the sweet tooth for the syntax. -- http://positionabsolute.net On Aug 3, 1:16 pm, Cédric bertolini.ced...@gmail.com wrote: Thanks. I'll use #bind instead of #bindAsEventListener from now on. Regarding the binding inelegancy, I'm a bit disappointed, but at least it's a good working solution to the problem. I guess Class#addMethods won't be of any help 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: get controls array
Hey Diego, I'd suggest learning CSS, in particular CSS Selectors. Second read up on prototype, you were a dollar sign away from almost having it. In your case, the name is too inconsistent, you could have almost gotten away with $$(input[name~=opt) but alas there is no space after it so it fails. As an alternative, looking at your code you just do... $$(input [type=text]) or if your collection requisites are more specific, add a class to the elements you want to collect and then simply $ (.myClass) -- http://positionabsolute.net On Jul 23, 5:50 pm, diegoturriaga diegoturri...@gmail.com wrote: I have something like that: tr tdPEPE/td tdinput ... name=opt[0][]input ... name=opt[0][] ... input ... name=opt[0][]/td tdselect ... name=selA[].../select/td tdselect ... name=selB[].../select/td /tr tr tdJUAN/td tdinput ... name=opt[1][]input ... name=opt[1] []...input ... name=opt[1][]/td tdselect ... name=selA[].../select/td tdselect ... name=selB[].../select/td /tr ... tr tdTITO/td tdinput ... name=opt[n-1][]input ... name=opt[n-1][] ... input ... name=opt[n-1][]/td tdselect ... name=selA[].../select/td tdselect ... name=selB[].../select/td /tr I want to get the array opt[x] using prototype but $('opt[x]') give me only the first instance. I need something like getElementsByName but using prototype :) Sorry for my english... --~--~-~--~~~---~--~~ 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: Masked Input in Prototype
You must further define your idea of masked input http://www.google.com/search?q=define%3A+masked+inputie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:officialclient=firefox-a On Jul 23, 3:58 pm, Celso cels...@gmail.com wrote: Anyone know a masked input in prototype? Thanks, Celso. --~--~-~--~~~---~--~~ 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: Need help for performantly creating tooltips
I think one of the easiest ways to handle tooltips is just let the native browser deal with it, using the title attribute with imgs and anchor elements will pop a 100 word tip on what the action will take. So just create the tool with a title attribute and then you're good to go. --- http://positionabsolute.net On Jul 22, 10:53 pm, Trevan Richins develo...@ckiweb.com wrote: On 7/22/2009 11:05 AM, Chris wrote: moverListener: function(e) { elm = Event.findElement(e, '.' + this.classes); if(elm !== undefined) { this.showToolTip(elm) } else return; }, moutListener: function(e) { elm = Event.findElement(e, '.' + this.classes); if(elm !== undefined) { this.hideTooltip(elm); } }, . I've found Event.findElement to be really slow in IE6. I've always rewritten it to just loop through the parents and do a quick check for each item. The reason findElement was been slow for me is that it asks the selector class for all items in the page that matches the selector, and then compares that list against the list of parents to see which ones it should return. And since IE6 can't use xpath, it is very slow. But this is definitely better than binding to each individual item, especially if you have a bunch of them. Eats up memory and bogs down the browser. --~--~-~--~~~---~--~~ 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: DataGrid
That is nice, you should submit it to http://scipteka.com -- http://positionabsolute.net On Jul 17, 4:14 am, Alex McAuley webmas...@thecarmarketplace.com wrote: Nice data grid! ... what about inline editing of the cells ? .. i cant get it to work on firefox in your demo - Original Message - From: nirbhab nirbhabba...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Thursday, July 16, 2009 7:32 AM Subject: [Proto-Scripty] DataGrid http://is.gd/1zDvChave a flexible datagrid...but sorting issue is there. --~--~-~--~~~---~--~~ 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: Objects that return zero length
Hmm, well you'd have to do a little extra filtering but no reason this isn't possible. assuming obj is your main structure you just posted do something like this... var edgeArr = $H(obj.nodes).keys().findAll(function(itr){ return ! (obj.nodes[itr].edges instanceof Array);}).collect(function(key) { return obj.nodes[key]; }); edgeArr is now an array of all objects that have a valid edges structure. ps. You owe me one pint of beer. On Jul 14, 10:47 pm, ronman ron.new...@gmail.com wrote: Yes, that's pretty close. attr is an object with properties, and one of those, attr.edges, is a nested object with its own nested sub- objects. All these properties and objects are constructed by evalJson () and then put in a $H() in a manner very similar to what you just described. I've copied a sample of the structure below. I was assuming that putting this whole thing within $A() would make the individual members (properties and objects) iterable, but perhaps I'm misunderstanding and instead every property and sub-object must be iterable (that is, understand the [] operator and have a length() method). Unfortunately, when the sub-object edges is empty, then running each () on the hash that contains it fails. arr.each(function(edgeProperty){ // fails if arr is an empty Hash. works if arr is an empty Array. fails if arr is a filled Array. Notice that the first edges is empty and the second one has one member: Brainwriting. from json: { nodes: { Brain Writing : { label: BRAIN\\nWRITING , height: 0.50, width: 0.83, fontsize: 10.00, fontcolor: white, pos: [ 570, 213 ], id: 1695, onmousedown: startdrag('1695'), length: 1, edges: [ ] }, A Perfect Brainstorm : { label: A PERFECT\\nBRAINSTORM\\n, height: 0.50, width: 1.11, fontsize: 10.00, fontcolor: white, pos: [ 326, 167 ], class: node, onmousedown: startdrag('1701'), length: 1, edges: { Brainwriting : { color: black, penwidth: 0.5, fontname: Arial, URL: javascript:void(predwin(2179)), label: bull; , } Ron blog.ideatree.us On Jul 14, 4:47 pm, Matt Foster mattfoste...@gmail.com wrote: Oh I get it now, attr.edges isn't an array of edge objects, its just an object with a series of properties that define an edge to your shape? If that is the case and you wish to iterate over the properties and execute set on them explicitly, you could do something like... var arr = $H(attr.edges).keys(); arr.each(function(edgeProperty){ this[edgeProperty].set(...); }, attr.edges); On Jul 14, 3:09 pm, ronman ron.new...@gmail.com wrote: Here's what I'm doing now: $A(attr.edges).each(function(edge) { edge.set(id, new GraphEdge(cv, id, edge)); }, this); Same result. The iterator.length shows zero and the inside of the loop never executes. But the iterator is (correctly, I think) 'Object Brainwriting =Object' Just casting around, I also tried taking off the binding to 'this' at the end, doesn't help. As before, I'm not getting why anything whatsoever that's in an array shouldn't automatically return length 0. On Jul 14, 1:47 pm, Matt Foster mattfoste...@gmail.com wrote: $A(attr.edges).each(function(edge) { this.edge.set(id, new GraphEdge(cv, id, edge)); }, this); edge is your variable, why bother trying to set function ownership? The function is sent the parameter it needs to act upon. Just remove this from your this.edge... line and you should be good. -- http://positionabsolute.net On Jul 14, 2:28 pm, ronman ron.new...@gmail.com wrote: This is a newbie question, but I learn a lot every time I ask. Why do some objects return a zero length? I'm doing Array.each. In the array at this particular time is a single object. Firebug describes that object as Object Brainwriting color=black penwidth=0.5 fontname=Arial and I iterate through the array this way: $A(attr.edges).each(function(edge) { this.edge.set(id, new GraphEdge(cv, id, edge)); }, this); But in Prototype's each method the 'edge' iterator (the Brainwriting Object), returns zero length: function $A(iterable) { if (!iterable) return []; if (iterable.toArray) return iterable.toArray(); var length = iterable.length || 0, results = new Array(length); // LENGTH NOW IS ZERO while (length--) results[length] = iterable[length]; return results; } Maybe the Brainwriting Object is not iterable, but I would expect $A (attr.edges) to have made it so before my call to each(). Surely I'm not expected to assign a length attribute to objects myself - just
[Proto-Scripty] Re: mixin of function not found
Factory pattern in a nutshell is using the same source for all creation of a particular class, such that all instances can be prepared identically. The source being a method, probably a member of a class, you always reference this method to create a new instance instead of calling new Class directly in your implementation. The advantage of this is that when your implementation wants all instances to have a particular property set you can set it in this central method before it gets returned instead of having to run around your code and find everytime you instantiated it. Or even better, the factory method returns a subclass that has this property/function already built in. http://en.wikipedia.org/wiki/Factory_method_pattern Element is not an instance nor does it a extend from Class/ Class.create so you can't swap this sort of functionality. The following will not work as you're anticipating. var CanvasElement = Class.create(Element, { myMethod : function(){ // } }); var myCanvas = new CanvasElement(); myCanvas.myMethod(); //fail -- http://positionabsolute.net On Jul 14, 12:26 pm, ronman ron.new...@gmail.com wrote: OK on using addMethods. Makes sense, and it's working for me. Very nice. Thanks. About not assigning functions after creation without a good factory method, I'm confused. Isn't that what the example is doing on the Prototype example at: http://prototypejs.org/learn/class-inheritance ? // define a module var Vulnerable = { wound: function(hp) { this.health -= hp; if (this.health 0) this.kill(); }, kill: function() { this.dead = true; } }; // the first argument isn't a class object, so there is no inheritance ... // simply mix in all the arguments as methods: var Person = Class.create(Vulnerable, { initialize: function() { this.health = 100; this.dead = false; } }); var bruce = new Person; bruce.wound(55); bruce.health; //- 45 On Jul 13, 4:22 pm, Matt Foster mattfoste...@gmail.com wrote: The second argument is accepting attributes of the HTML element. It isn't just assigning values to the object like Object.extend style. I'd recommend using Element.addMethods, and scope it to only canvas elements, that way each time you create a canvas you'll have this method available, but it won't pollute other elements with this special functionality. Element.addMethods('canvas', ...); http://prototypejs.org/api/element/addMethods You could also assign the function value after creation, but unless you're using a good factory pattern, you could easily get instances of canvas without your specialized method. You can't send methods to the constructor like that, just won't work. The declaration for Element is a bit bizarre so it can be hard to find, so here it is... (function() { var element = this.Element; this.Element = function(tagName, attributes) { attributes = attributes || { }; tagName = tagName.toLowerCase(); var cache = Element.cache; if (Prototype.Browser.IE attributes.name) { tagName = '' + tagName + ' name=' + attributes.name + ''; delete attributes.name; return Element.writeAttribute(document.createElement(tagName), attributes); } if (!cache[tagName]) cache[tagName] = Element.extend (document.createElement(tagName)); return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); }; Object.extend(this.Element, element || { }); if (element) this.Element.prototype = element.prototype; }).call(window); -- http://positionabsolute.net On Jul 13, 2:40 pm, ronman ron.new...@gmail.com wrote: Why doesn't 'getCoordinates' show up in the following code? canvas.getCoordinates() throws an error of getCoordinates is not a function I'm making a newbie error somewhere. var canvas = new Element('canvas', { width: this.xform(data.size[0]) + 16 + 'px', height: this.xform(data.size[1]) + 16 + 'px', // mixin to Element for canvases getCoordinates: function(element){ var position = this.getPosition(element), size = this.getSize (); var obj = {left: position.x, top: position.y, width: size.x, height: size.y}; obj.right = obj.left + obj.width; obj.bottom = obj.top + obj.height; return obj; }, } --~--~-~--~~~---~--~~ 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: Ajax Request Timeout
Hey Rick, My proposed idea in that article requires you to actually redefine the Ajax.Request. If we can solidify the idea we could submit the code as a patch to core but as of now you've gotta either replace it in the source library itself or just redefine it after the library but before any implementation. Review that demo page to see how I had done it and you could probably get it working. On Jul 14, 1:57 pm, Rick dun...@googlemail.com wrote: hi But leaving aside status 0, just a logical point. The third condition in your updated code: return (status = 200 status 300 status != 0); ...is irrelevant and will never be evaluated. If 200 = x 300, x cannot be zero. i can't believe what piece rubbish of code i have written, my brain must have bin offline :'( i think the zero comes from that part: --- line: 1499-- getStatus: function() { try { return this.transport.status || 0; } catch (e) { return 0 } } --- so Firefox must leave the status undefined. @ Matt Foster : i tried your patch but it didn't work for me, but maybe its my fault ... maybe it was a bad day of coding for me :) i will try it again yes the Ajax part off prototype is a bit uncomfortable by the way sorry I am not a native English speaker, so don't be mad with 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-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: Objects that return zero length
Oh I get it now, attr.edges isn't an array of edge objects, its just an object with a series of properties that define an edge to your shape? If that is the case and you wish to iterate over the properties and execute set on them explicitly, you could do something like... var arr = $H(attr.edges).keys(); arr.each(function(edgeProperty){ this[edgeProperty].set(...); }, attr.edges); On Jul 14, 3:09 pm, ronman ron.new...@gmail.com wrote: Here's what I'm doing now: $A(attr.edges).each(function(edge) { edge.set(id, new GraphEdge(cv, id, edge)); }, this); Same result. The iterator.length shows zero and the inside of the loop never executes. But the iterator is (correctly, I think) 'Object Brainwriting =Object' Just casting around, I also tried taking off the binding to 'this' at the end, doesn't help. As before, I'm not getting why anything whatsoever that's in an array shouldn't automatically return length 0. On Jul 14, 1:47 pm, Matt Foster mattfoste...@gmail.com wrote: $A(attr.edges).each(function(edge) { this.edge.set(id, new GraphEdge(cv, id, edge)); }, this); edge is your variable, why bother trying to set function ownership? The function is sent the parameter it needs to act upon. Just remove this from your this.edge... line and you should be good. -- http://positionabsolute.net On Jul 14, 2:28 pm, ronman ron.new...@gmail.com wrote: This is a newbie question, but I learn a lot every time I ask. Why do some objects return a zero length? I'm doing Array.each. In the array at this particular time is a single object. Firebug describes that object as Object Brainwriting color=black penwidth=0.5 fontname=Arial and I iterate through the array this way: $A(attr.edges).each(function(edge) { this.edge.set(id, new GraphEdge(cv, id, edge)); }, this); But in Prototype's each method the 'edge' iterator (the Brainwriting Object), returns zero length: function $A(iterable) { if (!iterable) return []; if (iterable.toArray) return iterable.toArray(); var length = iterable.length || 0, results = new Array(length); // LENGTH NOW IS ZERO while (length--) results[length] = iterable[length]; return results; } Maybe the Brainwriting Object is not iterable, but I would expect $A (attr.edges) to have made it so before my call to each(). Surely I'm not expected to assign a length attribute to objects myself - just lilke 'penwidth' and 'color' were assigned - in order to make Array.each() work on objects. Why doesn't the Object.length return non-zero when any kind of Object is instantiated? I'm using Firefox 3.0.10. --~--~-~--~~~---~--~~ 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: Ajax Request Timeout
Yeah I discuss the idea of having its own event for timing out in my article. The argument is a timeout is a failure, its failed to retrieve a response in the given time. So a timeout is basically like an inherited event from onFailure. Question remains do you seperate the event or just add a flag to the XHR to indicate the reason for failure is its timed out. Obviously you side with the latter as did Tobie so perhaps it would be best to dispatch both events for ease of implementation. Also that success method looks exactly like what TJ suggested and I posted, so good going on that. On Jul 14, 3:56 pm, Rick dun...@googlemail.com wrote: currently i just fixed the success function success: function() { var status = this.getStatus(); return (status = 200 status 300); }, and just watch the onFailure and onException event. But i would like to have an onTimeout event, so if we get an solution for a crossbrowser working onTimeout event, we can submit it. I have read about an solution but this one was rejected because it didn't worked in safari, etc. --~--~-~--~~~---~--~~ 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: select option by value
You could use many of the enumerable methods, this seems a bit verbose but gets the job done. Enumerable.find will iterate over the collection until the iteration function returns a value of true. I could have used each, but potentially would have iterated more than necessary, as we'd really want to halt search after a successful find. http://prototypejs.org/api/enumerable/find $A(select.options).find(function(option, index){ if(option.value == someValue){ select.selectedIndex = index; return true; } return false; }); -- http://positionabsolute.net On Jul 7, 4:58 pm, Martín Marqués martin.marq...@gmail.com wrote: I'm trying to select an option from a select, but by value, and not by index. I'm trying like this: function selectOptionByValue(selectID,valor){ var found = false; var i = 0; while(!found iselectID[0].options.length){ if(selectID[0].options[i].value == valor) { selectID[0].options[i].selected=true; found = true; } i++; } } I would call this function passing as argument the DOM object of the select and the option value that should be selected. Is there an easier way of doing this? BTW, it's not working for me. -- Martín Marqués select 'martin.marques' || '@' || 'gmail.com' DBA, Programador, Administrador --~--~-~--~~~---~--~~ 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: Events in own Class
This will work, but remember that the instance isn't going to actually fire an event, its just really acting as liaison to the document object to fire off events via document. You've somewhat namespaced the event with your reference ID which is going to make things difficult for anything attempting to observe an event from an instance. document.observe(observable_ + myInstance._refID + :onFoo); Prototype's custom events are events that can fire from a DOM instance, which will bubble to parents and can be caught at the top or wherever along the propagation chain. What I believe you are looking for is events fired from a function/class instance. You can get the function instance to throw an event by using the scripts i posted above. -- http://positionabsolute.net On Jun 29, 5:07 pm, Sven stuebe...@googlemail.com wrote: ok i tryed something... var Observable = Class.create({ initialize : function(){ this._refID = Observable.prototype.refCount++; }, observe : function(name, handler){ document.observe('observable_' + this._refID + ':' + name, handler); }, fire : function(name){ document.fire('observable_' + this._refID + ':' + name); } }); Object.extend(Observable.prototype, {refCount : 0}); var Test = Class.create(Observable, { initialize : function($super){ $super(); }, foo : function(){ this.fire('onFoo'); } }); is only a prototype for testing. Is it the right way or not? thanks, rgds sven On 29 Jun., 20:17, Matt Foster mattfoste...@gmail.com wrote: I ran into this same issue and made a class to extend others from to inherit this sort of functionality. This is the article but the JS itself is a bit outdatedhttp://positionabsolute.net/blog/2007/06/event-dispatcher.php To get the freshest JS...http://positionabsolute.net/includes/javascripts/EventDispatcher.js On Jun 29, 12:56 pm, Sven stuebe...@googlemail.com wrote: hmm but wait this is a global event... i want a instance-based event. xyz.foo(); //alert(barbarbar); abc.foo(); // alert(1234); and second $('bla').hide(); rgds sven On 29 Jun., 18:41, Sven stuebe...@googlemail.com wrote: wow thank you ;) On 29 Jun., 18:38, Rick Waldron waldron.r...@gmail.com wrote: Dig it: http://jsbin.com/uhogi (view the source) Rick On Mon, Jun 29, 2009 at 12:19 PM, Sven stuebe...@googlemail.com wrote: Hi, is it possible to add Events to own classes? something like this: var myClass = Class.create({ foo : function(){ this.fire('bar'); } }); var xyz = new MyClass(); xyz.observe('bar', function(){alert(barbarbar);}); rgds sven --~--~-~--~~~---~--~~ 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: Events in own Class
I ran into this same issue and made a class to extend others from to inherit this sort of functionality. This is the article but the JS itself is a bit outdated http://positionabsolute.net/blog/2007/06/event-dispatcher.php To get the freshest JS... http://positionabsolute.net/includes/javascripts/EventDispatcher.js On Jun 29, 12:56 pm, Sven stuebe...@googlemail.com wrote: hmm but wait this is a global event... i want a instance-based event. xyz.foo(); //alert(barbarbar); abc.foo(); // alert(1234); and second $('bla').hide(); rgds sven On 29 Jun., 18:41, Sven stuebe...@googlemail.com wrote: wow thank you ;) On 29 Jun., 18:38, Rick Waldron waldron.r...@gmail.com wrote: Dig it: http://jsbin.com/uhogi (view the source) Rick On Mon, Jun 29, 2009 at 12:19 PM, Sven stuebe...@googlemail.com wrote: Hi, is it possible to add Events to own classes? something like this: var myClass = Class.create({ foo : function(){ this.fire('bar'); } }); var xyz = new MyClass(); xyz.observe('bar', function(){alert(barbarbar);}); rgds sven --~--~-~--~~~---~--~~ 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: Working out where a user is on the page
When your event fires just get the scroll properties from the window, Prototype has a convenient method just for this purpose. http://prototypejs.org/api/document/viewport/getscrolloffsets -- http://positionabsolute.net On Jun 11, 9:30 am, Jeztah webmas...@thecarmarketplace.com wrote: At the time of a function call is it possible to work out where the user is on the page (scroll wise) without something being clicked or moved. I have an error function i built and it scrolls down to the center of the whle page (including anything past the scrollbar) - example of the viewport is 600px high and the whole page is 1000px high it will scroll so 500px is the middle of the screen as the use sees it But, this is annoying if the error was generated from an action at the top of the page as it scrolls down 500px to show the error - making the user effectvely scroll back up!... It would be great if my function was aware of the user's position on the page - the only problem is ... the function is only passed a string to disply in the error at present so i have no reference to see its offsets on the page to work this stuff out.. so i was wondering if it can be done without passing an element into the funciton to work it out!.. Regards Alex --~--~-~--~~~---~--~~ 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] Returning scriptaculous drag/drop elements via ajax
This might be a simple problem but I just can't get my head round it. I'm designing a page with two lists, on the left is a list of 'Activity Groups' and on the right, a list of children that have not yet been allocated to an Activity Group. To allocate a child to a group, you simply drag them to the correct activity group on the left. Once this is done, an ajax request fires off to update the database and return the two new lists with the content updated. Trouble is it doesn't work. When the child is dropped on the correct group on the left, the onDrop function is not fired. I suspect that this is because dropzone is 'hidden' by the fact that it has come back by ajax. Is there any way round this? Matt --~--~-~--~~~---~--~~ 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: HTML breaks JSON
You guys are crazy...you send json_encode an object, not a string!! http://us3.php.net/manual/en/function.json-encode.php -- http://positionabsolute.net On Jun 5, 6:16 am, Alex McAuley webmas...@thecarmarketplace.com wrote: very strange .. works for me with anything all the time - Original Message - From: Matt guitarroman...@gmail.com To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Friday, June 05, 2009 10:05 AM Subject: [Proto-Scripty] Re: HTML breaks JSON Hi Alex, Still didn't work for me :( Just produced broken HTML output again. On Jun 4, 5:24 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: You need to do it a bit differently with php json_encode/decode ... i had this problem when i first started using it where you send post data (JSON) as p $post=str_replace('\', '', $_POST['p']); $json=$post; $d=json_decode($json,true); foreach($d as $key=$val) { .. do what you will with it after this unless you know the key names !! This should do the trick for you HTH ALex - Original Message - From: Matt i...@leedsguide.co.uk To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Thursday, June 04, 2009 4:30 PM Subject: [Proto-Scripty] Re: HTML breaks JSON Hi again, I've been running addslashes() on the input before running json_encode () and it still creates problems when I pass it through AJAX - breaks HTML tags etc. If I turn addslashes() off, any occurence of in the body text (eg quotes from speakers etc) breaks the code again. Does anyone have a foolproof method? Cheers Matt On Apr 24, 9:54 pm, Matt Foster mattfoste...@gmail.com wrote: What are you sending to PHP's json_encode? It is expecting a structure to serialize into a JSON syntax string. $struct = array(message = h1Hello World/h1Who says we can't have any kind of \quotes\ we want?); echo json_encode($struct); If you try to run json_encode on your already JSONified string, yeah its going to cause problems... -- http://positionabsolute.net On Apr 24, 12:26 pm, T.J. Crowder t...@crowdersoftware.com wrote: @Ananth: Converting to Base64 would be massive overkill, surely. @OP: There's no reason you can't include strings containing HTML in JSON data. You just have to make sure your strings are valid string literals, like this: { message: pThis is HTML./p } There's nothing special other than making sure the HTML is correctly escaped -- e.g., if you're putting the JSON string in double quotes, naturally any double quotes in the HTML will need a backslash in front of them -- as, for that matter, will any backslashes! HTH, -- T.J. Crowder tj / crowder software / com On Apr 24, 5:05 pm, Ananth Raghuraman araghuram...@gmail.com wrote: JSON should not contain HTML for tactical/ease of programming purposes unless the HTML is there as part of a larger design, but there may or may not be implementation restrictions. If you are facing problems, can you try encoding the HTML string (Base64) and decoding back (using Javascript Base64 code ) before display on the browser? On Fri, Apr 24, 2009 at 11:30 AM, Matt guitarroman...@gmail.com wrote: Hi there, I'm using PHP to output some JSON through AJAX to my page. It breaks whenever I use a backslash or quote mark. I've tried using php's json_encode function which doesn't seem to help, just breaks it further. I've also tried php's addslashes() to the output, again, same problem. Am I approaching this correctly, fundamentally? Is JSON supposed to contain HTML? Thanks, Matt --~--~-~--~~~---~--~~ 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: HTML breaks JSON
Hi Alex, Still didn't work for me :( Just produced broken HTML output again. On Jun 4, 5:24 pm, Alex McAuley webmas...@thecarmarketplace.com wrote: You need to do it a bit differently with php json_encode/decode ... i had this problem when i first started using it where you send post data (JSON) as p $post=str_replace('\', '', $_POST['p']); $json=$post; $d=json_decode($json,true); foreach($d as $key=$val) { .. do what you will with it after this unless you know the key names !! This should do the trick for you HTH ALex - Original Message - From: Matt i...@leedsguide.co.uk To: Prototype script.aculo.us prototype-scriptaculous@googlegroups.com Sent: Thursday, June 04, 2009 4:30 PM Subject: [Proto-Scripty] Re: HTML breaks JSON Hi again, I've been running addslashes() on the input before running json_encode () and it still creates problems when I pass it through AJAX - breaks HTML tags etc. If I turn addslashes() off, any occurence of in the body text (eg quotes from speakers etc) breaks the code again. Does anyone have a foolproof method? Cheers Matt On Apr 24, 9:54 pm, Matt Foster mattfoste...@gmail.com wrote: What are you sending to PHP's json_encode? It is expecting a structure to serialize into a JSON syntax string. $struct = array(message = h1Hello World/h1Who says we can't have any kind of \quotes\ we want?); echo json_encode($struct); If you try to run json_encode on your already JSONified string, yeah its going to cause problems... -- http://positionabsolute.net On Apr 24, 12:26 pm, T.J. Crowder t...@crowdersoftware.com wrote: @Ananth: Converting to Base64 would be massive overkill, surely. @OP: There's no reason you can't include strings containing HTML in JSON data. You just have to make sure your strings are valid string literals, like this: { message: pThis is HTML./p } There's nothing special other than making sure the HTML is correctly escaped -- e.g., if you're putting the JSON string in double quotes, naturally any double quotes in the HTML will need a backslash in front of them -- as, for that matter, will any backslashes! HTH, -- T.J. Crowder tj / crowder software / com On Apr 24, 5:05 pm, Ananth Raghuraman araghuram...@gmail.com wrote: JSON should not contain HTML for tactical/ease of programming purposes unless the HTML is there as part of a larger design, but there may or may not be implementation restrictions. If you are facing problems, can you try encoding the HTML string (Base64) and decoding back (using Javascript Base64 code ) before display on the browser? On Fri, Apr 24, 2009 at 11:30 AM, Matt guitarroman...@gmail.com wrote: Hi there, I'm using PHP to output some JSON through AJAX to my page. It breaks whenever I use a backslash or quote mark. I've tried using php's json_encode function which doesn't seem to help, just breaks it further. I've also tried php's addslashes() to the output, again, same problem. Am I approaching this correctly, fundamentally? Is JSON supposed to contain HTML? Thanks, Matt --~--~-~--~~~---~--~~ 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: Event.toggle
Is there a way to initially load the page with the map open and then close it after a timed period? Better yet, is there some way to load it with it hidden but not chopped up? Yeah, having it display:none or visibility:hidden can muck up the calculations of the containers dimensions. I'd suggest the good ole trick of hiding IFrames, which is just set the container as { position:absolute; left: -4000px; } This way the map is off the view port hence invisible to the user and yet fully accessible via the DOM for dimension calculations. Thinking more about it, you may not want to instantiate the map until you're ready, nothing says it has to be done on page load, I had done some work with Ext.js and Google maps, where Ext does the DOM element creation all via JS execution, i loaded the map only when it was necessary. http://positionabsolute.net/projects/javascript/ext/googleservice/ -- http://positionabsolute.net On Jun 5, 5:09 am, MIGhunter ad...@botdls.com wrote: I'm trying to use a script to hide and show user information. Right now I am just playing with it and here is what I have:http://migcfdesign.com/joani/index.html The problem is the map. I can't load the page with the map hidden. If I do chops off 1/2 of the map. Is there a way to initially load the page with the map open and then close it after a timed period? Better yet, is there some way to load it with it hidden but not chopped up? I'm not sure what's the conflict is between google's js and prototype.js. The url to a copy of the map messing up is:http://migcfdesign.com/joani/index2.html Here is the code I am using: html head titleToggle Test/title meta http-equiv=Content-Type content=text/html; charset=utf-8 / meta name=viewport content=initial-scale=1.0, user-scalable=no / script src=/javascripts/lib/prototype.js type=text/javascript/ script script src=/javascripts/src/scriptaculous.js type=text/ javascript/script script type=text/javascript src=http://maps.google.com/maps/api/ js?sensor=true/script script type=text/javascript Event.observe(window, 'load', function() { Event.observe('featurebox-3-listen', 'click', function(){ $('featurebox-3').toggle(); }); }); Event.observe(window, 'load', function() { Event.observe('featurebox-4-listen', 'click', function(){ $('featurebox-4').toggle(); if($('featurebox-4').hide()){ $('featurebox-4-listen').update('(812)555-'); } else { //do nothing. } }); }); Event.observe(window, 'load', function() { Event.observe('featurebox-5-listen', 'click', function(){ $('featurebox-5').toggle(); if($('featurebox-5').hide()){ $('featurebox-5-listen').update(' Street Bloomington, IN 47401'); } else { //do nothing. } }); }); function initialize() { var latlng = new google.maps.LatLng(39.1485520, -86.5857814); var myOptions = { zoom: 13, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById (map_canvas), myOptions); } /script /head body onload=initialize() table tr tdimg src=images/map_symbol.jpg alt=Map title=Map/td tdpspan id=featurebox-3-listena href=#strongMap (Hide) /strong/a/span | span onclick=$('featurebox-3').toggle();a href=#strongMap (Show)/strong/a/span/p/td div class=featurebox id=featurebox-3div class=featurebox id=featurebox-2 pdiv id=map_canvas style=width:50%; height:50%/div/p /div /tr tr tdimg src=images/phone_symbol.jpg alt=Phone title=Phone Number/td tdspan id=featurebox-4-listena href=#strongPhone Number/ strong/a/span/td
[Proto-Scripty] Re: HTML breaks JSON
Hi again, I've been running addslashes() on the input before running json_encode () and it still creates problems when I pass it through AJAX - breaks HTML tags etc. If I turn addslashes() off, any occurence of in the body text (eg quotes from speakers etc) breaks the code again. Does anyone have a foolproof method? Cheers Matt On Apr 24, 9:54 pm, Matt Foster mattfoste...@gmail.com wrote: What are you sending to PHP's json_encode? It is expecting a structure to serialize into a JSON syntax string. $struct = array(message = h1Hello World/h1Who says we can't have any kind of \quotes\ we want?); echo json_encode($struct); If you try to run json_encode on your already JSONified string, yeah its going to cause problems... -- http://positionabsolute.net On Apr 24, 12:26 pm, T.J. Crowder t...@crowdersoftware.com wrote: @Ananth: Converting to Base64 would be massive overkill, surely. @OP: There's no reason you can't include strings containing HTML in JSON data. You just have to make sure your strings are valid string literals, like this: { message: pThis is HTML./p } There's nothing special other than making sure the HTML is correctly escaped -- e.g., if you're putting the JSON string in double quotes, naturally any double quotes in the HTML will need a backslash in front of them -- as, for that matter, will any backslashes! HTH, -- T.J. Crowder tj / crowder software / com On Apr 24, 5:05 pm, Ananth Raghuraman araghuram...@gmail.com wrote: JSON should not contain HTML for tactical/ease of programming purposes unless the HTML is there as part of a larger design, but there may or may not be implementation restrictions. If you are facing problems, can you try encoding the HTML string (Base64) and decoding back (using Javascript Base64 code ) before display on the browser? On Fri, Apr 24, 2009 at 11:30 AM, Matt guitarroman...@gmail.com wrote: Hi there, I'm using PHP to output some JSON through AJAX to my page. It breaks whenever I use a backslash or quote mark. I've tried using php's json_encode function which doesn't seem to help, just breaks it further. I've also tried php's addslashes() to the output, again, same problem. Am I approaching this correctly, fundamentally? Is JSON supposed to contain HTML? Thanks, Matt --~--~-~--~~~---~--~~ 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: How can I get a list of events fired by an object?
The iframe element doesn't support any events[1]. You can indeed listen to the load event directly from the IFrame element. http://pastie.org/493154 The document that it contains may support various events (such as load, click, etc.). Why would a document inside an iframe not support these events? -- http://positionabsolute.net On May 21, 8:46 pm, RobG rg...@iinet.net.au wrote: On May 22, 12:11 am, Walter Lee Davis wa...@wdstudio.com wrote: I'd like to see what events are there for the observing, particularly on an iframe. The iframe element doesn't support any events[1]. The document that it contains may support various events (such as load, click, etc.). Is there a general-purpose way (or even some tab of Firebug I haven't seen before) that I can see what events are being fired? Some sort of Event.observe('foo','*'... kind of thing? Try Firebug's Profile option. 1. URL:http://www.w3.org/TR/html401/present/frames.html#edef-IFRAME -- Rob --~--~-~--~~~---~--~~ 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: How can I get a list of events fired by an object?
I'm pretty sure you can listen to the iframe's load event for that... I don't think it bubbles so you'll have to listen to it on the iframe itself and not on a parent. I use that event extensively in my ajax history solution, http://positionabsolute.net/blog/2007/07/javascript-history-service.php -- http://positionabsolute.net On May 21, 5:39 pm, Walter Lee Davis wa...@wdstudio.com wrote: Thanks, it appears that the only way that I'll be able to work around this is with a timed observer pattern, there doesn't seem to be an event fired by an iframe into the page context when its src changes. The underlying problem was how to keep an iframe sized to match its contents. While you get one onload event when the frame finishes loading, no others are ever fired, even when you navigate to a different page within the iframe. Walter On May 21, 2009, at 5:05 PM, Matt Foster wrote: You could find a list of all events and listen to them each, there isn't an all operator to listen to any event that is fired as far as I know... --~--~-~--~~~---~--~~ 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: How can I get a list of events fired by an object?
You could find a list of all events and listen to them each, there isn't an all operator to listen to any event that is fired as far as I know... function allYourEventAreBelongToUs(e){ console.log(You hit an event %o, e); } $w(load unload click dblclick ...).each(function(evenType){ $(ele).observe(eventType, allYourEventAreBelongToUs); }) Here is a list I found of most events in JS, just remove the on obviously for your purposes... http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.3 -- http://positionabsolute.net On May 21, 10:11 am, Walter Lee Davis wa...@wdstudio.com wrote: I'd like to see what events are there for the observing, particularly on an iframe. Is there a general-purpose way (or even some tab of Firebug I haven't seen before) that I can see what events are being fired? Some sort of Event.observe('foo','*'... kind of thing? Thanks in advance, Walter --~--~-~--~~~---~--~~ 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: Observe onmouseover and onmouseout with IE6
What is surprising to me is that the this scope ever actually worked inside the event handlers. Had you left the handle alone I know that Proto would have bound the element to the handler such that this would assume the value of the element, but since you explicitly set this via bind in the iterable function, it should have overwritten that. The value of this in the iterable function is window, so you're really binding window to the event handler's owner scope, not the element at large. If this worked though, then somewhere in this idea I'm mistaken but I cannot see where. -- http://positionabsolute.net On May 20, 1:54 am, Dravis plu...@gmail.com wrote: I have this bit of code in my webpage's header. It simply pulls all the li elements from the mainmenu and attaches onmouseover and onmouseout event observers to them to toggle the drop down effects of the menu. It works perfectly in IE7 and Firefox but when I mouse over the menu in IE6 I get nothing. Anyone have any ideas? document.observe(dom:loaded, function() { $$('#mainmenu li').each(function(item) { $(item).observe(onmouseover, function() { $(this).addClassName(sfhover); }.bind(this)); $(item).observe(onmouseout, function() { $(this).removeClassName(sfhover); }.bind(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] Re: Check element class against array
var test = ['foo', 'bar', 'foob']; if (test.any(element.hasClassName.bind(element))) { I believe using the non-methodized version of this method would be better Element.hasClassName.curry(element); -- http://positionabsolute.net On May 14, 12:30 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, I can think of two approaches off-hand: 1. Use Enumerable#include on the array of classes you want to test against, using Element#hasClassName as the iterator function (bound to the instance), e.g.: var test = ['foo', 'bar', 'foob']; if (test.any(element.hasClassName.bind(element))) { // ... } or if (['foo', 'bar', 'foob'].any(element.hasClassName.bind (element))) { // ... } (You don't need to use $A() around array literals.) 2. Use $w on the class name to get an array of the individual class names, then use Enumerable#any on that, passing in Enumerable#include on the array you want to test against as the #any iterator. Something like this: var test = ['foo', 'bar', 'foob']; if ($w(element.className).any(test.include.bind(test))) { log(true); } (Both of those bits of code are untested.) But if this is going to be happening a lot (a tight loop, or a mouseover handler, etc.), check the runtime cost of each of these by going under the covers. FWIW, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 13, 7:34 pm, louis w louiswa...@gmail.com wrote: I have an array containing a number of strings. I would like to continue exucuting my script only if an item has ANY/ALL of the strings assigned as a class name. $A(['foo', 'bar', 'foob']); Is there an elegant want to do this without having to loop through the items? --~--~-~--~~~---~--~~ 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: Check element class against array
I think you misinterpreted what I was saying. Simply swapping bind for curry will certainly generate errors. I don't really feel like explaining it and its of potentially trivial performance results but, savor some of this syntax... var ele = $(container); var arr = $w(foo bar derka); var bool = arr.any(Element.hasClassName.curry(ele)); console.log(bool);//if this throws an error, get firebug!! ... div id=container class='foo'/div -- http://positionabsolute.net On May 14, 5:04 pm, louis w louiswa...@gmail.com wrote: Thanks guys. I am going to compare the difference in processing time of TJ's suggestions. It will be called often (from a Form Observer). For now I am using this one: if (_validate_field_classes.any(element.hasClassName.bind (element))) { Wasn't aware of the any function. Matt. I tried swapping bind for curry and it gave an error. On May 14, 3:32 pm, Matt Foster mattfoste...@gmail.com wrote: var test = ['foo', 'bar', 'foob']; if (test.any(element.hasClassName.bind(element))) { I believe using the non-methodized version of this method would be better Element.hasClassName.curry(element); -- http://positionabsolute.net On May 14, 12:30 pm, T.J. Crowder t...@crowdersoftware.com wrote: Hi, I can think of two approaches off-hand: 1. Use Enumerable#include on the array of classes you want to test against, using Element#hasClassName as the iterator function (bound to the instance), e.g.: var test = ['foo', 'bar', 'foob']; if (test.any(element.hasClassName.bind(element))) { // ... } or if (['foo', 'bar', 'foob'].any(element.hasClassName.bind (element))) { // ... } (You don't need to use $A() around array literals.) 2. Use $w on the class name to get an array of the individual class names, then use Enumerable#any on that, passing in Enumerable#include on the array you want to test against as the #any iterator. Something like this: var test = ['foo', 'bar', 'foob']; if ($w(element.className).any(test.include.bind(test))) { log(true); } (Both of those bits of code are untested.) But if this is going to be happening a lot (a tight loop, or a mouseover handler, etc.), check the runtime cost of each of these by going under the covers. FWIW, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 13, 7:34 pm, louis w louiswa...@gmail.com wrote: I have an array containing a number of strings. I would like to continue exucuting my script only if an item has ANY/ALL of the strings assigned as a class name. $A(['foo', 'bar', 'foob']); Is there an elegant want to do this without having to loop through the items? --~--~-~--~~~---~--~~ 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: Please Help With Code
I think he's looking for a snippet handout, by the looks of the spaghetti that he's pasted he's trying to highlight a single item in a menu. var activeElement = false; $$(ul.menu li).invoke(observe, click, function(e){ var element = e.element(); if(activeElement) activeElement.removeClassName(active); element.addClassName(active); activeElement = element; }); }); -- http://positionabsolute.net On May 8, 5:50 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, There are lots of code examples in the resource I pointed you to, particularly the unofficial wiki. For instance, one aspect of what you're trying to do is hook events. That's very thoroughly covered with lots of examples in the API docs[1] and on the wiki[2][3]. So again, have a read through and you'll be well on your way. [1]http://prototypejs.org/api/element/observe [2]http://proto-scripty.wikidot.com/prototype:tip-hooking-events [3]http://proto-scripty.wikidot.com/prototype:how-to-hooking-events Enjoy! -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 8, 9:22 am, z...@zanepaul.com.au z...@zanepaul.com.au wrote: Thanks for your reply, Im very new at this and was hoping more for some code to as a starting point? On May 8, 3:39 am, T.J. Crowder t...@crowdersoftware.com wrote: Hi, Prototype can definitely help you with that. Off the top of my head, the Prototype methods you want are Element#observe[1] (which is a convenience wrapper for Event.observe[2]) and probably Element#addClassName[3] and Element#removeClassName[4]. [OT (e.g., not Prototype-related) you might want to use === and !== in your comparisons of object instances, rather than == and != (see the ECMAScript spec[5] for more on identity comparisons).] If you're just getting started with Prototype, it's _well_ worth your time having a read through the API[6] from beginning to end. It takes about an hour, and saves you hours and hours in return. The learn[7] page and the unofficial wiki[8] may also be useful. [1]http://prototypejs.org/api/element/observe [2]http://prototypejs.org/api/event/observe [3]http://prototypejs.org/api/element/addClassName [4]http://prototypejs.org/api/element/removeClassName [5]http://www.ecma-international.org/publications/standards/Ecma-262.htm [6]http://prototypejs.org/api [7]http://prototypejs.org/learn [8]http://proto-scripty.wikidot.com HTH! -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On May 8, 5:53 am, z...@zanepaul.com.au z...@zanepaul.com.au wrote: Im trying to get this code working in FireFox and Sarfari var changeStyleColour = function () { var active = null, newclass = colourActive; if (this.Event.addEventListener) this.Event.addEventListener ('onUnload', function () {active = null;}); return function (element) { if ((active != element) element.className) { if (active) active.className = colourNormal; element.className = newclass; active = element; } }; }(); Can someone please help- Hide quoted text - - Show quoted 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 -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Ajaxio next step?
Another good one is www.mindmeister.com, I doubt they've got an API for you to work with but maybe you can get some ideas. Its built with Proto/scripty, but they use a canvas object instead of SVG so it could be a bonus for your IE requirement. -- http://positionabsolute.net On May 5, 11:21 am, Gecko sneakyliz...@gmail.com wrote: Thanks James, I had done some research on your demo (I even tried the newest versions of the library scripts) and was hoping you still monitored this group. Ryan thank you for the suggestion. Wireit does seem promising (although it’s current version fails in IE7, they seem to be working on a fix and I will attempt to us their dev version). Amazingly fast response from both of you, thank you very much. On May 5, 9:01 am, Diodeus diod...@gmail.com wrote: I wrote Ajaxio as an exercise to learn how to use Prototype Scriptaulous several years ago. I had it to the point where I could have the drawing as an XML file and reload it from XML data, but I lost the source code. I've had many enquiries from people who have taken it for their own purposes, but I haven't really heard anything back from anyone. I was reworking parts of Walter Zorn's library in order to make the connector lines clickable, but never got that part finished. It was intended more as a demonstration than a step towards a workable product. To tell you the truth, it's kinda crappy and I've learned a lot about JavaScript since then, as I did just building it. I'm glad it gave you some inspiration, but unfortunately Ajaxio is a non-entity. - James. On May 4, 6:30 pm, Gecko sneakyliz...@gmail.com wrote: Anyone ever do anything with or similar to James MacFarlane'shttp://jameslab.moveable.com/ajaxio/demo. It is exactly what I need to work with inside a browser based application using soap web services. The problem is that is it fails in IE7 8 (which are my target users). And yes I am extremely new to javascript so it may be a very simple fix that I am not seeing. --~--~-~--~~~---~--~~ 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: Effect.Appear doesn't work when in queue
In looking at your code, there were a few HTML mistakes. First your try me element doesn't have a proper closing div tag its just /div no greater than to close the tag. You've also does this on your input buttons, input objects are considered simple, meaning they have no children, so having a separate closing tag is bad practice. You have... input type=button onclick=return gotoNewAccount (document.getElementById('newUserTextbox').value); id=newUserSubmitFromHome value=create account/input it should be input type=button onclick=return gotoNewAccount (document.getElementById('newUserTextbox').value); id=newUserSubmitFromHome value=create account/ -- http://positioanbsolute.net On Apr 30, 10:55 pm, alpineedge3 gmarzl...@gmail.com wrote: thanks for the reply. i removed the quotes from the duration but it still does not work. On Apr 26, 12:38 pm, Diodeus diod...@gmail.com wrote: function barcodeFlyToSimLeft(){ new Effect.Move('barcodeLeft',{x: -350, y: 200, mode: 'relative'}); new Effect.Shrink('barcodeLeft',{direction: 'center', queue: 'end', afterFinish: function(){Barcode('043396097742');}}); new Effect.Appear('barcodeLeft',{x: 0, y:0, duration: '1.0', queue: 'end'}); return false; } Duration should be numeric, not a string. On Apr 24, 5:26 pm,alpineedge3gmarzl...@gmail.com wrote: Hi, I'm running an effect chain: move, shrink, then appear. The appear effect doesn't fade in. rather, it just becomes visible with 100% opacity. The scripts are controlling the barcode boxes on the homepage ofwww.fastpricecheck.com. Any help would be appreciated. Thanks! --~--~-~--~~~---~--~~ 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: Event.observe
Hey Brent, Do you have a demo page that displays this issue? My only thoughts are that the elements are getting reloaded in the DOM yet not getting the events attached. -- http://positionabsolute.net On Apr 29, 2:59 pm, BrentNicholas brentnicho...@gmail.com wrote: Hi all, So I posted about this before but am still having troubles with Event.observe flaking out on me after a period of time. Here's the situation: The page runs and init's the app with: document.observe(dom:loaded, init); init() fires off: getSelectsForm() As you can see (below) it loads a page and attaches some observers, the page loaded only has three buttons on it (as seen in the Event.observe code). They are not of the same names or id's, but do share the same css class names. Nothing else is loaded. Now if I click any button right away things work just fine (List Page, Add Page). If I wait about 5 minutes (not pressing any buttons first after load) the 'buttonGetProjectsList' will not seem to fire the 'getProjectsList' function as registered through the observer. However the button 'buttonAddProjectForm' will fire off the 'addProject' function. Even if you start using the page right away (everything works), then wait 5 minutes, the list button will not work but the others will. The pages loaded by these button do not have any elements of the same name or id on them that the ''dsp_ProjSelects.cfm' file had. So there should not be any naming conflicts. Any thoughts on this? I've taken the application and stripped in down to just what's needed in a test area and I'm still getting the trouble. function getSelectsForm() { new Ajax.Request('dsp_ProjSelects.cfm?'+cfSession, { method: 'get', onSuccess: loadSelectsForm, onComplete: attachSelectsFormObservers, onFailure: function(r) { throw new Error( r.statusText ); } } ); } function loadSelectsForm(transport) { var htmlBlock = transport.responseText; Element.update(idSelectsDIV,htmlBlock); Form.focusFirstElement('SELECT_FORM'); } function attachSelectsFormObservers() { Event.observe('buttonGetProjectsList','click', getProjectsList, false); Event.observe('buttonAddProjectForm','click', addProject, false); Event.observe('buttonClearForm','click', clearSelectsForm, false); } Also, environment: Win XP (all patches) IE 6.0.2900.2180.xpsp.080413-2111 Thanks for your time and effort. Brent --~--~-~--~~~---~--~~ 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: pimp my snippet?
Just to have fun with it... var val = $F(file); if(val.lastIndexOf( ) val.lastIndexOf(/)) On Apr 29, 2:52 pm, Walter Lee Davis wa...@wdstudio.com wrote: Aha, but what about spaces in folders leading up to that filename? I don't mind those, since I only end up with the file, not the entire local path. Which was why I did the split + last() trick. A file field reports its value to JavaScript as the entire root-relative path to the file on the user's computer in some browsers (Safari for sure). Walter On Apr 29, 2009, at 1:53 PM, Diodeus wrote: if($F(file).indexOf( )) { alert('darnammit, no spaces Wilbur!') } On Apr 29, 1:29 pm, Walter Lee Davis wa...@wdstudio.com wrote: Trying to keep people from uploading files with spaces in their filenames: //inside a change event observer on the field if($F(file) $F(file).split(/(\/|\\ \)/).last().include( )) ... //warning here Can anyone suggest a more elegant route? Thanks, Walter --~--~-~--~~~---~--~~ 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: Extracting methods from codebase
I'd set up each class or major structure, such as Element, Enumerable, etc etc as its own file, then define packages such as minimal, efficient, advanced, ajax...etc. Then in a server side script it will bundle these files together depending on the package so you could make a request something like prototype-package.php?package=advanced and it will pull only files that you have set up as the advanced package. I find that lazy loading either leads to lost dependencies or in most cases leads to more overhead than if you had just loaded it all in one request. When using the packaging server side script you can also use tactics of minify and gzipping to reduce the payload. -- http://positionabsolute.net On Apr 29, 12:46 pm, Bertrand bertrand.char...@gmail.com wrote: Hi, My code makes use of Element's update method. It handles modification of an element's contents gracefully and isn't as risky as innerHTML. My problem is that I don't know how to extract it from the code (I wish I could link to Google's Prototype, but I work in an environment where filesize is critical). The issue at hand is that the method makes use of other bits (bind, defer, stripScripts, $A, etc.) from the library that would in turn pull other bits and so forth. My question is : Is there a way to smartly cherry-pick the bits I need from the source code without breaking anything. My previous attempts at doing just that were utter failures and reverting back to innerHTML is ground for disaster as well. Any help appreciated. Thanks, Bertrand. PS: A solution would be to have some sort of preprocessor directives like //@dependsOn: defer, bind, $A... for each method so that a script could create custom builds of the library that would fit the user's needs perfectly (one could even imagine a web interface where the user would indicate the functions he wants to use, hit generate to obtain a custom version of Prototype). Sprockets seems to be a step in that direction but it's not fine- grained enough in my opinion. --~--~-~--~~~---~--~~ 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] HTML breaks JSON
Hi there, I'm using PHP to output some JSON through AJAX to my page. It breaks whenever I use a backslash or quote mark. I've tried using php's json_encode function which doesn't seem to help, just breaks it further. I've also tried php's addslashes() to the output, again, same problem. Am I approaching this correctly, fundamentally? Is JSON supposed to contain HTML? Thanks, Matt --~--~-~--~~~---~--~~ 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: HTML breaks JSON
What are you sending to PHP's json_encode? It is expecting a structure to serialize into a JSON syntax string. $struct = array(message = h1Hello World/h1Who says we can't have any kind of \quotes\ we want?); echo json_encode($struct); If you try to run json_encode on your already JSONified string, yeah its going to cause problems... -- http://positionabsolute.net On Apr 24, 12:26 pm, T.J. Crowder t...@crowdersoftware.com wrote: @Ananth: Converting to Base64 would be massive overkill, surely. @OP: There's no reason you can't include strings containing HTML in JSON data. You just have to make sure your strings are valid string literals, like this: { message: pThis is HTML./p } There's nothing special other than making sure the HTML is correctly escaped -- e.g., if you're putting the JSON string in double quotes, naturally any double quotes in the HTML will need a backslash in front of them -- as, for that matter, will any backslashes! HTH, -- T.J. Crowder tj / crowder software / com On Apr 24, 5:05 pm, Ananth Raghuraman araghuram...@gmail.com wrote: JSON should not contain HTML for tactical/ease of programming purposes unless the HTML is there as part of a larger design, but there may or may not be implementation restrictions. If you are facing problems, can you try encoding the HTML string (Base64) and decoding back (using Javascript Base64 code ) before display on the browser? On Fri, Apr 24, 2009 at 11:30 AM, Matt guitarroman...@gmail.com wrote: Hi there, I'm using PHP to output some JSON through AJAX to my page. It breaks whenever I use a backslash or quote mark. I've tried using php's json_encode function which doesn't seem to help, just breaks it further. I've also tried php's addslashes() to the output, again, same problem. Am I approaching this correctly, fundamentally? Is JSON supposed to contain HTML? Thanks, Matt --~--~-~--~~~---~--~~ 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: Observe div content change?
Anath's idea would be ideal but I am not sure how supported that event actually is. Alternatively, it'd be a bit more work but still would satisfy your event requisite of just firing off you own event when you update. var oldHTML = ele.innerHTML; ele.update(text); ele.fire(x:update, { oldHTML : oldHTML }); http://prototypejs.org/api/element/fire -- http://positionabsolute.net On Apr 22, 10:33 am, Ananth Raghuraman araghuram...@gmail.com wrote: $(your element id).observe(DOMCharacterDataChanged,function(evt){ //your code here }); Try above Check the Event.Observe documentation on prototype api documentation website. This website gives you a link to DOM 2 Events list. Check the Mutation Events section. On Wed, Apr 22, 2009 at 7:02 AM, Yozefff yoze...@gmail.com wrote: Is it possible to observe when the content of a DIV is changed? So for example, I update the innerHTML (ajax perhaps?) and some JS class is listening when the content is changed. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---