My point still stands that it is a simple example... when we delve deeper into more complex examples it becomes garder and harder!!... Also fom what i can remember about the code it took 2 requests to complete as opposed to 1.... surely that is not memory efficient...
I dont deny it can probably all be done with non inline i just dont aggree that its better to do it due to script size, time to write, number of requests, memory & scalability..... To the best of my knowledge OOP is used for the re-usablility of code/functions (certainly in php anyway), i for one like to reuse my functions in PHP, Javascript and other languages if only to keep the size of things to a minimum and my code is written for me not for other people to be able to read (luckily) !!! This is probably a good debate to have in an open group like this as alot of people new to Javascirpt programming are told not to inline things but not really explained the real reasons why or why not to!! - same with php and ' vs " !! Long day for me time to hit the hay ! Regards Alex ----- Original Message ----- From: Rick Waldron To: [email protected] Sent: Thursday, June 04, 2009 11:30 PM Subject: [Proto-Scripty] Re: Working outside loop, but not inside What about when all that inline markup is output from a loop...lots of rendered source code that will likely look like spaghetti? The markup created by my example is just: (i've changed "record" to "name" in the example) <li class="clicker"><a id="a_001" name="001" href="javascript:;">Mystery Character #001</a> Furthermore, it takes on average 100ms to load and render the initial data from the server and between 10-20ms to click-load-process the second server call. Numbers aside - that's super fast, but profiling and net monitoring from one server to one client machine isnt proof of anything. Anyway... glad we could open that up to more conversation. Rick On Thu, Jun 4, 2009 at 4:28 PM, Alex McAuley <[email protected]> wrote: That was a very basic example i wrote !!... Plus your code is not re-usable which was kinda my point and its about 50 lines where as mine would fit into perhaps 10 or so... inline is alot more flexible... In basic examples yes this way does work but is memory expensive and alot of work !!!... As i said - each to thier own in thier coding style ... while inline is still valid xhtml i will continue to use it Also ... is the "record" node on the href's valid xhtml ? because i cant see it on the list of valid nodes!... And i would rather use inline callees than use invalid xhtml! Regards Alex ----- Original Message ----- From: Rick Waldron To: [email protected] Sent: Thursday, June 04, 2009 7:29 PM Subject: [Proto-Scripty] Re: Working outside loop, but not inside @Alex, I think i met all of your criteria: http://genevajs.com/misc/demo-ps-list-0011.php i left the js in the main file so you could reference. dig it. Rick On Thu, Jun 4, 2009 at 12:20 PM, Alex McAuley <[email protected]> wrote: @Rick -- Okay here is a good one..... A very dynamic site where you need to pull varying variables -- excuse the psudeo code !! just proving its needed sometimes !! funciton doSomething({options}) { new Ajax.Updater(options.element,options.url, { method:options.method, evalScripts: options.evalscripts, parameters: { options.parametersName: options.params } onComplete: options.onCompleteFunction // Not sure if would work - as i've never tried }); } <div onclick="doSomething({element:'myDiv',url:'myurl.php',evalscrips:true,parametersName:'postbody',params:'<?php echo($myVeryDynamicVariableIJustRecievedFromAnotherAjaxRequestThatTheDocumentCouldNotPossiblyKnowWithoutUpdatingLotsOfHiddenVariables); ?>',onCompleteFunction:'function(){alert(\'Hi\');}'});"> </div> Now without inline handlers i would have to make alot of functions.. this way i can reuse my code and just change the inputs .... I will state i dont do this often but sometimes it is needed as a script cannot always get the variables it needs as some change dynamically from other requests and outside factors I built an extremely dynamic Web Desktop over the last 2 years which is alot faster than anything else out there... One of the main factors it stays fast is the client memory is not clogged up with huge initial downloads of functions that only get used every now and again!. My view is each to thier own .... If it aint broke dont fix it and if everyone wrote code the same then the internet would be boring !! I would be interested to see how you would tackle problems like the one above as i've never really discussed it with anyone before Regards Alex ----- Original Message ----- From: Rick Waldron To: [email protected] Sent: Thursday, June 04, 2009 4:06 PM Subject: [Proto-Scripty] Re: Working outside loop, but not inside A quick google for "php single quotes vs double quotes" will help you understand the difference and what it means to the overhead and scalability of your code. I picked this article from said google results: http://andrewgatenby.com/single-quotes-and-double-quotes-in-php @Alex, I honestly can't think of any scenario where it is ok to use inline handlers, but I'm definitely interested in hearing your argument regarding them. I'm of the belief that complete separation of logic is imperative and should be regarded as best practice (or even, "only practice")... thoughts? @Craig, Apparently Effect.toggle() does not like the element chained to it... odd. Anyway, you can improve this much further.... I've posted a demo. http://genevajs.com/misc/demo-ps-list-0010.php Rick --~--~---------~--~----~------------~-------~--~----~ 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---
