Re: [Proto-Scripty] Ajax problem
On 24 Jun 2019, at 22:51, Walter Lee Davis wrote: > > Yup. That will stop a JavaScript insertion like you want to do cold. Try > replacing all of the newlines [and carriage returns, if any] with a single > space before you pass that value back to the Ajax request. It doesn't matter > how long the line is, as long as it's one line. I generally substitute > /[\n\r]+/ with ' ‘. Thanks, Walter, but I’ve just this minute found the problem, and it was, as I knew it would be, a stupid one. Where I had "$('thisid').up('ul').insert (newhtml);”, all I had to do was take the quotes away from round ‘thisid’! I was sending a literal string to $ instead of the value represented by the variable and, oddly enough, there isn’t an element in the DOM with the id ‘thisid’! And btw, it does work with a few ‘\r's in it. Thanks a million for your help. Now I have to fix the next problem... -- Cheers... Chris Chris Sansom: composer and… whatnot http://www.chrissansom.net/ https://www.youtube.com/channel/UCVUKb7vK0KiIaiLhs7zht2Q https://soundcloud.com/mfthoad As every parent of a small child knows, converting a large object into small fragments is considerably easier than the reverse process. — Andrew S. Tanenbaum -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To unsubscribe from this group and stop receiving emails from it, send an email to prototype-scriptaculous+unsubscr...@googlegroups.com. To post to this group, send email to prototype-scriptaculous@googlegroups.com. Visit this group at https://groups.google.com/group/prototype-scriptaculous. To view this discussion on the web visit https://groups.google.com/d/msgid/prototype-scriptaculous/8C59F928-105C-459A-A646-ABAB4BC27438%40gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Proto-Scripty] Ajax problem
Hi again Walter > On 23 Jun 2019, at 16:09, Walter Lee Davis wrote: > > One of the best ways to work this out is to build a cut-down example, in one > page, that tries to do what you're after here. If you can get that to fail, > post it as a Gist or similar. From your description, you're going about > things the right way. I’ve followed your advice to make a stripped-down version of the problem (though I’m afraid I’ve no idea what a Gist is), and it answered one of my two problems: there was something wrong with my XML (it may have been as basic as the wrong Content-type), so js ignored the response. However, it still won’t insert the new code where I want it (or indeed anywhere). I’ve narrowed it down, I’m pretty sure, to a problem of scope - and I’m sure it’s basic stuff. I don’t need to bore you with the very simple initial html or the even simpler code executed by the Ajax call, because I know that’s all fine now, but here’s the relevant js: var base = 'http://10.0.1.2:90/~dvds/'; // initialization routines document.observe ('dom:loaded', function() { // set up handler for variable numbers of selects var addselects = $$('.addselect'); for (var i = 0; i < addselects.length; i++) { var addselect = addselects[i]; addselect.onchange = newSelect; } }); // handler for adding new field to array function newSelect() { // var thisid = this.id; var newhtml; var url = base + 'ajaxtest'; // send request to do the business var myAjax = new Ajax.Request (url, { method: 'post', onSuccess: function (req) { var xml = req.responseXML; var id = xml.getElementsByTagName('id')[0].firstChild.nodeValue; if (id) { newhtml = '\t\t\r\t\t\t\r\t\t\t\t\r'; // loop var newid, newname; var ids = xml.getElementsByTagName('id'); var names = xml.getElementsByTagName('name'); for (var i = 0; i < ids.length; i++) { newid = ids[i].firstChild.nodeValue; newname = names[i].firstChild.nodeValue; newhtml += '\t\t\t\t' + newname + '\r'; } newhtml += '\t\t\t\r\t\t\r'; // $('thisid').up('ul').insert (newhtml); } else { alert (’ng'); newhtml = 'No good.'; } }, onFailure: function() { alert ('Script failure.'); newhtml = 'No good.'; } }); // alert (newhtml); if (newhtml) { this.up('ul').insert (newhtml); } } What I need to do is /either/ make the value of the original ‘this' available to the inner part of the code (the line that’s commented out immediately after the last html += …) /or/ make newhtml available to the pouter part of the code for the 'if (newhtml)’ block at the end. But I can’t figure out how to do it because it doesn’t meet my normal assumptions about global and local variables. I really feel I’m almost there with this problem - just this last hurdle to get over! -- Cheers... Chris Chris Sansom: composer and… whatnot http://www.chrissansom.net/ https://www.youtube.com/channel/UCVUKb7vK0KiIaiLhs7zht2Q https://soundcloud.com/mfthoad Goodness is about what you do. Not who you pray to. — Terry Pratchett -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To unsubscribe from this group and stop receiving emails from it, send an email to prototype-scriptaculous+unsubscr...@googlegroups.com. To post to this group, send email to prototype-scriptaculous@googlegroups.com. Visit this group at https://groups.google.com/group/prototype-scriptaculous. To view this discussion on the web visit https://groups.google.com/d/msgid/prototype-scriptaculous/5B879D02-856C-4BC0-B20D-3C6A039BC0B9%40gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Proto-Scripty] Ajax problem
Hi Walter Thanks for your long and thoughtful response… some of which I understood! (I did say I was rusty, and I was never extremely advanced - never got into OOP for instance unless it was laid out on a plate for me as prototype does). Just a quick question - do you know whether there’s some limit to the length of a string that can be returned via Ajax, and whether it can contain carriage returns, tabs or whatever? What I’m returning here is politely formatted and indented html with 76 options in the select. > On 23 Jun 2019, at 16:09, Walter Lee Davis wrote: > > One of the best ways to work this out is to build a cut-down example, in one > page, that tries to do what you're after here. If you can get that to fail, > post it as a Gist or similar. From your description, you're going about > things the right way. > > One other piece of advice. Rather than using a numerical index to get the > first of some collection, try making your method iterate over the found > results and operate conditionally. This will give you another place to put > console.log statements to further refine exactly what is going on inside: > >> var newhtml = xml.getElementsByTagName('newhtml')[0].firstChild.nodeValue; > > When you say that the correct code to insert is there in the Ajax response, > that cuts that part of the problem out, and your example page can just do > something dumb like this: > > var data_to_insert = $('some_example_element').remove().innerHTML.toString(); > > ...where you have a DOM element like ... your element here ...> > > I have found over the years that when you have the correct element (legally > possible to insert into a given container), then Prototype (and the browser) > just does what you'd expect. But if what you are getting back from the server > doesn't make any sense in terms of your DOCTYPE (say you are trying to insert > raw text into a , rather than trying to insert a , then the browser > will just ignore you. It's not a Prototype error, in other words, just the > browser being pedantic when being called in a JS update mode. > > Finally, see if you can get your server to return the HTML of the picker, > fully rendered. Then you should be able to do this: > > new Ajax.updater('parent_element_id', '/server/url', { > parameters: { foo: 'bar', ...}, // optional, pass to your server some > parameters > insertion: 'bottom' // this lets you put the rendered element at the bottom > of the existing children of the parent > }); > > If #parent_element_id is a , then the HTML you get from > /server/url?foo=bar should be: > > > > > > > > ... with all of the whitespace removed. > > Walter > >> On Jun 22, 2019, at 11:25 AM, Chris Sansom wrote: >> >> With apologies in advance for the length... >> >> I retired a few years ago from web development, where I used Prototype quite >> a bit in the later years. I'm somewhat rusty now, but I'm trying to do some >> development for purely personal use. It won't be on the open web, just on >> our local server. It's all been going fine (if slowly!), but now I've hit a >> brick wall with Ajax. >> >> Here's what I'm trying to do: >> * I have a form with one or more s, each within its own , all >> in the one . >> * Each contains the same list of items from a table in a MySQL >> database. >> * The last has nothing selected and has the class "addselect". >> * The idea is that if I select something from that last , an >> onChange event is triggered which calls an Ajax script to add a new >> (containing the same items). This is set up on page load in a >> "document.observe ('dom:loaded', function()..." at the top of the javascript >> file. >> * Each has a sequential name and id, eg 'name="country[0]" >> id="country_0"', the next country[1] and country_1, and so on. The newly >> created would have the next name and id in sequence. >> I hope that all makes some sense. >> >> So... >> The handler function set up in 'dom:loaded...' gets the next index number >> for the name and id of the new , and sends this ('entryindex') and >> the name of the table to search ('list') to the Ajax script, and off we go: >> >> var pars = 'list=' + list + '=' + newIndex; >> var url = base + 'ajaxgetmenu'; >> >> // send request to do the business >> var myAjax = new Ajax.Request (url, { >> method: 'post', >> parameters: pars, >> onSuccess: function (req) { >> var xml = req.responseText
[Proto-Scripty] Ajax problem
With apologies in advance for the length... I retired a few years ago from web development, where I used Prototype quite a bit in the later years. I'm somewhat rusty now, but I'm trying to do some development for purely personal use. It won't be on the open web, just on our local server. It's all been going fine (if slowly!), but now I've hit a brick wall with Ajax. Here's what I'm trying to do: * I have a form with one or more s, each within its own , all in the one . * Each contains the same list of items from a table in a MySQL database. * The last has nothing selected and has the class "addselect". * The idea is that if I select something from that last , an onChange event is triggered which calls an Ajax script to add a new (containing the same items). This is set up on page load in a "document.observe ('dom:loaded', function()..." at the top of the javascript file. * Each has a sequential name and id, eg 'name="country[0]" id="country_0"', the next country[1] and country_1, and so on. The newly created would have the next name and id in sequence. I hope that all makes some sense. So... The handler function set up in 'dom:loaded...' gets the next index number for the name and id of the new , and sends this ('entryindex') and the name of the table to search ('list') to the Ajax script, and off we go: var pars = 'list=' + list + '=' + newIndex; var url = base + 'ajaxgetmenu'; // send request to do the business var myAjax = new Ajax.Request (url, { method: 'post', parameters: pars, onSuccess: function (req) { var xml = req.responseText; ... This far, everything is hunkydory. Safari's Web Inspector shows exactly the correct result - a nice new with the correct name and contents - under 'XHRs' in its Resources tab. So I know the script is being called and is operating correctly. But where it falls over is with what comes next: var newhtml = xml.getElementsByTagName('newhtml')[0].firstChild.nodeValue; This, incidentally, is taken from a script I developed back in my professional days which I know worked perfectly. But something is failing here, cuz it don't work! If I put an alert in ('ok') before this line, it pops up, but if I put it after this line it doesn't. And yet no errors are reported. And of course the next line doesn't work either: $('thisid').up('ul').insert (newhtml); (And I know "$('thisid')" is right because I put that in an alert to check it.) So I simplified it. I abandoned XML and made the result plain text instead, to be inserted verbatim. Again, the script produces a perfect result in Safari's Web Inspector, but even when newhtml is plain text (and I skip the xml.getElementsByTagName line altogether), it fails. And again, an alert before the insert line works, but not one after it. I've tried everything I can think of, so if anyone has any wisdom on this I'd be very grateful indeed. It's probably something dead obvious staring me in the face... -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To unsubscribe from this group and stop receiving emails from it, send an email to prototype-scriptaculous+unsubscr...@googlegroups.com. To post to this group, send email to prototype-scriptaculous@googlegroups.com. Visit this group at https://groups.google.com/group/prototype-scriptaculous. To view this discussion on the web visit https://groups.google.com/d/msgid/prototype-scriptaculous/fb84d882-af7d-45f8-a400-b98701228f19%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Proto-Scripty] Image cache problem with Ajax
Right - time to deal with all these helpful answers I've been getting, but first, to save time, let me say... it's fixed! And a very simple fix it was too, which I /thought/ I'd already tried... On 29 Sep 2011, at 17:15, Richard Quadling wrote: Create a test case where it goes wrong. Write new clean code that doesn't want/need/use anything from the main project. I had just prepared such a project when I found the answer among the answers below! And on 29 Sep 2011, at 18:04, Phil Petree wrote: This is an interesting problem... my first reaction is that you'd want to use onComplete to update the div's instead of onSuccess. Test this with a couple of alerts and see which one gets called first and which is last (just as onCreate is the first call, onComplete is the last). Well I had already tried onComplete and it made no difference, but I tried your suggestion nevertheless and sure enough, wherever I put the alerts in the code of the callbacks, onSuccess always emerged before onComplete. It also didn’t matter (as I assumed it wouldn't) if I put the onComplete before the onSuccess in the code. Then on 29 Sep 2011, at 18:28, Phil Petree wrote: This guy had a solution that worked for me: http://www.irt.org/script/416.htm I had already tried using the time in a similar way to this, but it didn’t work. However, in the same message... I have also used the cheap trick of adding a random query string on to the end of the image url: http://www.somedomain.com/images/newname.jpg?id=random_number and since this will always generate a new url, the browser will refresh the image. That was the one! As I say, I thought I'd done that - or something very like it - in my numerous attempts at different solutions, but I obviously didn’t do exactly this, and it seems to work reliably every time in a suitably bulletproof fashion. So simple! It also seems to confirm that my initial suspicions were correct, and it is after all a caching issue, not to do with, er, asynchronicity (if that's a word - if not, Ive just invented it, so there). So many thanks for your time and thoughts, Richard and Phil, also ncubica and Walter for chipping in. -- Cheers... Chris Highway 57 Web Development -- http://www.highway57.co.uk/ -- 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.
Re: [Proto-Scripty] Image cache problem with Ajax
On 30 Sep 2011, at 12:32, Richard Quadling wrote: onFailure / onSuccess is in response to a working result from the AJAX call. onComplete is in response to the AJAX mechanism shutting down. onComplete will always be called, but it isn't its job to deal with the data from the call. That is onSuccess. If the call failed for some reason, onComplete wouldn't have any data to work with and could make things worse. I use onCreate and onComplete to turn on/off a little spinner showing that the app is doing something behind the scenes. Right - thanks. That could be useful. -- Cheers... Chris Highway 57 Web Development -- http://www.highway57.co.uk/ -- 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] Image cache problem with Ajax
I don't know if this is really something I can fix via Prototype, or if it's in any way a Prototype issue, but I'll try here first. Here is my problem - which unfortunately I can’t show you because I'm only developing it on my local system at the moment - slightly simplified: I have a pair of images on a page, one above the other. The user should be able to click the second one to swap them round, but I don't mean merely swapping their position on the page: this involves renaming the files. On the server, the first image is given a completely new name and the second is renamed with the first's old name. The div containing the two is then replaced by the magic of Ajax, except... the problem is that the image with the old name is cached (I think), so although the second image is indeed replaced by the first with its brand new name, the first image is unchanged, either because the previous image with that name is stuck in the cache or because it hasn’t had time to be reloaded due to the asynchronous nature of the process. Either way, I end up with two of the same image. If I then refresh the page altogether, I get the correct images. In sequence, this happens: - User clicks image - Ajax request is created, running a php script with various parameters, in which... - ...the necessary renaming takes place (which involves checking for duplicates etc.), then... - ...a php file is included* which does various processing to build up an output string for the replacement div... - ...in which all are replaced by [] so as not to confuse the xml return. - Back in JS, the [] are changed back to and the containing div is replaced. So is my problem the cache? Or is it simply that the scripts run faster than the replacement image can be loaded? I've tried various things to stop it caching, such as loading the top image via a tiny php script which sends all manner of no-cache type headers then does fpassthru, fread or whatever (I've tried it various ways) - this made no difference. I even tried including a sleep(1) command in this script! - no good. I've also tried preloading the image in JS before the new div is output - no good. Should I be trying to subvert (pervert?) Ajax into running synchronously somehow? I'm quite prepared to accept that I may be approaching this whole problem bass-ackwards, and would be grateful for any pointers. * I did this via an include file because I need to do the same processing when the page is initially loaded, so this seemed the most efficient way, code-wise. -- Cheers... Chris Highway 57 Web Development -- http://www.highway57.co.uk/ -- 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.
Re: [Proto-Scripty] Image cache problem with Ajax
On 29 Sep 2011, at 15:00, Chris Sansom wrote: I've tried various things to stop it caching, such as loading the top image via a tiny php script Forgot to mention, before anyone else does, that the first thing I tried, after Googling, was to put various query strings [such as '?' + (new Date()).getTime()] after the file name in the img tag. Didn’t work. -- Cheers... Chris Highway 57 Web Development -- http://www.highway57.co.uk/ -- 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.
Re: [Proto-Scripty] Image cache problem with Ajax
On 29 Sep 2011, at 15:51, Richard Quadling wrote: Does ALL the JS work take place inside the onSuccess callback? The Back in JS bit has to be part of the onSuccess callback otherwise it will happen out of sequence. The A in AJAX is potentially the hiccough here. That's what I suspected but yes, all the 'back in JS' stuff does indeed happen in the onSuccess. (I also tried onComplete, but got the same result.) I think the problem may be that the div, inevitably, is replaced right at the end of the process (at the end of the onSuccess), and only then is the offending img tag unleashed, calling either the image itself or my little php script... but then I'd have thought preloading it might help, but it doesn’t seem to. I also tried loading it via a php exec() call to the image script in advance of returning the output string to JS, but that didn’t help. What also convinces me that you're right about the A in AJAX is that when, for testing, I put a sleep(5) in the image script - which should hold it up by a whole 5 seconds - the div is still replaced immediately. When I first load the page (which also calls this script), I get a broken image icon where the image should have been, replaced after 5 seconds by the image, but when the div is replaced by the ajax call that doesn’t happen - I just get no change of image as before. It really would be /so/ nice if I could get this working! It's for a password-protected CMS, so the world at large will never get the benefit, and I could simply reload the whole page instead of just the one div, but it's become a challenge! -- Cheers... Chris Highway 57 Web Development -- http://www.highway57.co.uk/ -- 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] Problem with crossfading complex divs
Been off this list for ages, as I've not done any of this kind of work for some time. As a consequence I'm a bit rusty... OK, an explanation of what I'm trying to do. I have a div which consists of a row of three nested divs inside each of which are various elements, including links. The client wants this whole row of three to crossfade with a different set of three at regular intervals (I'm using 3 seconds with a two second fade time for testing purposes). They also want the crossfading to pause when the mouse is rolled over anywhere in the whole set of three, and resume on mouseout. I have two empty enclosing divs in the html page, pinned to the same spot with css. I use a Periodical Executer to do an Effect.fade() and Effect.appear() to crossfade them. This all works fine, but with the mouseover/-out part all hell can break loose! I first tried it with a simple pair of boxes, one green saying 'Hello' and one blue saying 'Goodbye', and this worked perfectly, but with the more complex version I'm running into what I think must be bubbling problems - and this is where I get a bit out of my depth, I'm afraid. I /think/ what's happening is that when you roll the mouse over various elements inside the div JS thinks it's mousing out and over repeatedly, so the animation goes nuts and at times disappears altogether. If you simply roll over one of the images, then straight out of the whole enclosing div again, on the other hand, the pause and resume works fine. It could well be that I'm approaching this completely the wrong way... -- Cheers... Chris Highway 57 Web Development -- http://www.highway57.co.uk/ -- 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.
Re: [Proto-Scripty] Problem with crossfading complex divs
On 13 Sep 2011, at 15:29, Chris Sansom wrote: I /think/ what's happening is that when you roll the mouse over various elements inside the div JS thinks it's mousing out and over repeatedly Just been out for a walk and had a think about this. I think what I need to do is somehow prevent the mouseout from restarting the fading if it's followed by a mouseover within, say, a quarter? a tenth? of a second. I'll see if I can find a way to do this, but any hints would be most welcome at this stage. -- Cheers... Chris Highway 57 Web Development -- http://www.highway57.co.uk/ -- 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.
Re: [Proto-Scripty] Problem with crossfading complex divs
On 13 Sep 2011, at 16:32, Pablo Aravena wrote: I think your problem is because you are using mouseover/mouseout instead of mouseenter/mouseleave Hi Pablo I told you I was rusty! That's exactly right - it now works beautifully. Well almost - it's still possible to mess it up by whipping the mouse repeatedly in and out or across a corner a few times. I'm not sure whether to take the attitude that it serves the user right if they're going to behave like that! Thanks for your help. -- Cheers... Chris Highway 57 Web Development -- http://www.highway57.co.uk/ -- 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?
At 19:47 -0700 30/9/09, tcupolo wrote: Turning the scroll wheel on the mouse while holding down the control key on the keyboard will enlarge/shrink the entire document image displayed in the window with focus. Surely this is more of a system-wide thing, at least on the Mac. If I do this, the entire /screen/ zooms in and out, regardless of what software is currently active. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Old professors never die; they just lose their faculties. --~--~-~--~~~---~--~~ 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] subscribing to event with element name starting with a certain text string
At 11:08 +0100 28/9/09, Alex McAuley wrote: I am sure that its a regex in the name= bit so a regilar expression something like (0-9Aa-Zz) would do it In that case, surely just (\w)? -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Anything played wrong twice in a row is the beginning of an arrangement. -- Frank Zappa --~--~-~--~~~---~--~~ 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] Dynamic test after ajax call
At 05:21 -0700 19/9/09, T.J. Crowder wrote: View source will only show you the original source of the document, not any later modifications you make to the DOM (e.g., via Ajax.Updater or any of several other means). Why does it matter? What is it you're trying to achieve looking at the source? If it's just that you're trying to debug the markup or something, you can use Firefox with the Firebug[1] add-on, which will show you the current DOM tree rather than the original source. Also the Web Developer add-on for Firefox has 'View Generated Source' which usually reflects such changes pretty well. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Heaven would be a place where bullshit existed only on television. -- Frank Zappa --~--~-~--~~~---~--~~ 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] POSTing a form via AJAX
At 10:54 -0400 22/8/09, bill wrote: Putting it all together (apparently wrongly) I have: $('messageProcessForm').observe('submit',function(event) { new Ajax.Updater('showMessageDiv', mail/process_message.php, { parameters: $('showMessageDiv').down('form').serialize(true), onFailure: function(response) { alert (mail.js: failure to submit form - getmessage); } Event.stop(event); // will stop it doing its default action! }); } When I try to load this I get the message: Error: missing } after property list Source File: http://192.168.0.101/MP2010-v2/scripts/mail.jshttp://192.168.0.101/MP2010-v2/scripts/mail.js Line: 33 Source Code: Event.stop(event); // will stop it doing its default action! but, I can't see a missing close bracket. Jumping in here as a non-expert, but I think the problem may be that your 'Event.stop(event);' is in the wrong place and should be outside the 'new Ajax.Updater(...)', either before or after, but not inside. It's when it hits that line that it's looking for the extra }. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ If we don't succeed, we run the risk of failure. -- Bill Clinton, former US President --~--~-~--~~~---~--~~ 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] POSTing a form via AJAX
At 11:21 -0400 22/8/09, bill wrote: now $('messageProcessForm').observe('submit',function(event) { new Ajax.Updater('showMessageDiv', mail/process_message.php, { parameters: $('showMessageDiv').down('form').serialize(true), onFailure: function(response) { alert (mail.js: failure to submit form - getmessage); } }); Event.stop(event); // will stop it doing its default action! } the error changes to: Error: missing ) after argument list Source File: http://192.168.0.101/MP2010-v2/scripts/mail.jshttp://192.168.0.101/MP2010-v2/scripts/mail.js Line: 36, Column: 1 Source Code: } ^ As far as I can see the parens and brackets are balanced Nope - just loaded this snippet into BBEdit which has a very handy facility for seeing whether pairs of brackets (of all types) are balanced. You have no closing ) to match the ( after '.observe'. In fact you need a ');' at the end of the whole thing. And btw, shouldn't mail/process_message.php be in quotes? -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ There is no reason anyone would want a computer in their home. -- Ken Olson Founder of DEC, 1977 --~--~-~--~~~---~--~~ 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] Need help for performantly creating tooltips
At 22:35 +0100 21/7/09, Alex McAuley wrote: I love semantical arguments !! Especially if you can pass them to a function. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ I'm on a seafood diet - I see food, I eat it. -- Dolly Parton --~--~-~--~~~---~--~~ 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] Need help for performantly creating tooltips
At 15:25 -0700 21/7/09, Chris wrote: If I have about 60 tooltips on page (that could load another subset of elements, that maybe have tooltips too), I would have about 120 listeners (each tooltip needs at least a mouseover and one mouseout, right?). Is it the right way to just add two listeners (as in my example in my first post), which fire only on the elements I want? This would take the needed listeners from about 120 to only 2, which seems to be a really nice thing. But if I do it with only two listeners, every time something is hovered, it uses the findElement()-method to check for a tooltip. So what is faster and less memory consuming? At the risk of stating the bleedin' obvious - and maybe there's a good reason why you can't do this - have you thought about simply sing title attributes for the elements? In most, if not all, modern browsers, they produce tooltips when the element is rolled over. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Computers in the future may weigh no more than 1.5 tons. -- 'Popular Mechanics', 1949 --~--~-~--~~~---~--~~ 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] Doctypes
I'm curious about the recent discussion that's arisen as a sideline from the 'Creating new lines and bypassing them through escapeHTML' thread. I've been using Prototype for a little while now (though not Scriptaculous - yet!). I'm not by any stretch of the imagination an expert and I'm sure I'm still not using it as fully as I could (I keep coming across things in the docs that make me go 'Doh! I could have been doing that all this time'). However, I've also been working exclusively in XHTML 1.0 Strict for some time and I haven't been aware of anything not behaving as advertised. Also, unless I've missed something obvious, I don't /think/ I've seen any reference to doctypes in the API docs or Tips Tutorials at prototypejs.org. So should I be changing my ways here? I seriously don't want to have to convert several large and complex PHP-driven sites to a different doctype if I can help it! -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Nobody looks good bent over. Especially to pick up a cheque. -- Frank Zappa --~--~-~--~~~---~--~~ 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: Trouble getting started with Prototype
At 22:10 -0700 28/5/09, Alex wrote: SCRIPT type=text/javascript src=javascriptPrototype.js / ... The Prototype functions are in javascriptPrototype.js. I am trying to remove (or delete the contents of if someone has a better idea) the div element with id=box. I get an error everytime in IE 7. Anyone have any tips or suggestions? Er, yes. The file is 'prototype.js', not 'javascriptPrototype.js', so try: SCRIPT type=text/javascript src=prototype.js / ...unless, for some reason, you've renamed the file which of course you're perfectly at liberty to do... -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Jazz is not dead...it just smells funny. -- Frank Zappa --~--~-~--~~~---~--~~ 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] Trouble getting started with Prototype
At 06:07 -0700 29/5/09, Alex wrote: What I downloaded from Prototype was titled: prototype-1.6.0.3.js. I renamed that file to javascriptPrototype.js so that I could use it. I uploaded it into my directory. And from there I got to the question I had above. Does that clear anything up or help at all? Is there anything else I should have titled prototype.js ??? Nope - I take it all back. :-) The other thing that occurred to me then was that maybe you weren't waiting for the DOM to finish loading before removing the element - though why you would want to remove an element immediately, rather than in response to some user action, I've no idea. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ The lead car is absolutely unique, except for the one behind it which is identical. -- Murray Walker --~--~-~--~~~---~--~~ 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] Trouble getting started with Prototype
At 10:01 -0400 29/5/09, Mitchell McCulloch wrote: Ah! I didn't look too closely at that I guess, whoops. Indeed that should solve the problem for Chris. No problem for me - at least, not /that/ problem. :-) I was the one who suggested he had the filename wrong when he didn't. The original problem was Alex's, and I hadn't noticed the lack of a /script either. I guess it may depend on how forgiving the browser is, but certainly if I remove it from one of my applications Firefox 3 doesn't like it. Could well be the answer then. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ A double negative is strictly a no-no --~--~-~--~~~---~--~~ 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: SyntaxError: unterminated string literal
At 17:24 +0300 21/5/09, Vladimir Tkach wrote: Prototype gsub error? $H({s:'\'}).toJSON() Result : SyntaxError: unterminated string literal I /think/, though the experts hereabouts will confirm or otherwise, that JavaScript thinks the \ is escaping the quote that comes after it. To do what you want, I believe you'd have to escape the backslash in turn: $H({s:'\\'}).toJSON() I hope that's right! -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Why do you necessarily have to be wrong just because a few million people think you are? -- Frank Zappa --~--~-~--~~~---~--~~ 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 Radio Box Question
At 04:20 -0700 30/3/09, simon.murgatr...@googlemail.com wrote: The problem is it only registers the call back on the first of the radio boxes. If I change the id on each input statement so each uses a differenet name, I can register three callbacks. But I want the radio boxes to operate as a set, with only a single possible value. I suspect I am going about this in the wrong way. What is the correct way to do this so that I get told as the user selects a different option? I've never used Form.Element.EventObserver, but I can tell you straight away what's wrong here: although your radios can (and indeed should) have the same /name/ to operate as a set in the form data, they /must/ have separate IDs in the HTML - the page won't validate if they have the same id (no two elements can share an id). They can, however, share the same class, so I suggest doing something like this: input type=radio id=rbEncAll class=rbEncryption name=rbEncryption value=All Allbr/ input type=radio id=rbEncYes class=rbEncryption name=rbEncryption value=YesEncryptedbr/ input type=radio id=rbEncNo class=rbEncryption name=rbEncryption value=NoUnencryptedbr/ But having, as I say, not used this call, I'm not sure how you register the callback. Someone else will have to advise on the detail, but you might be able to do something with: $$('input.rbEncryption').each (function... -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Everything Is More Difficult Than It Appears -- Adam C Engst --~--~-~--~~~---~--~~ 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 causes function with array/for...each to stop working
Oooh - don't say there's a post I can answer... At 02:12 -0700 23/3/09, jazzylicious wrote: I might get some replys with: So you do use prototype, but don't use it for everything??? I just couldn't find a way to do the same thing in prototype. ... var allDivs = new Array (divreferenties,divreferentie106,divreferentie107,divreferentie108,divreferentie109,divreferentie110,divreferentie111,divreferentie112,divreferentie113,divreferentie114,divreferentie115,divreferentie116,divreferentie117,divreferentie166,divreferentie209); document.getElementById('refterug').style.display = ''; for(s in allDivs) { document.getElementById(allDivs[s]).style.display = 'none'; } Try this instead: allDivs.each(function(s) { document.getElementById(allDivs[s]).style.display = 'none'; }); Or, even better: allDivs.each(function(s) { $(allDivs[s]).style.display = 'none'; }); -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Star Wars won't work. -- Frank Zappa --~--~-~--~~~---~--~~ 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] Stopping submit event
At 06:41 -0700 23/3/09, T.J. Crowder wrote: function venFormhandler(event) { event.stop(); /* ...do your ajaxy goodness... */ } That's the one! I was trying to be too complicated. Thank you. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ A censor is a man who knows more than he thinks you ought to. -- Laurence J. Peter --~--~-~--~~~---~--~~ 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 filtering data - best approach?
At 04:30 -0700 18/3/09, Matt wrote: As I say, I've managed to produce the basics, but have no idea how to use Prototype to a) build a complex WHERE query and b) 'toggle' the data when the user checks/unchecks a box. Don't use prototype to build the WHERE clause. Use prototype to send the parameters, then use those to build the WHERE clause in your PHP script. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Despite the high cost of living, it remains very popular. --~--~-~--~~~---~--~~ 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] AJAX filtering data - best approach?
At 05:51 -0700 18/3/09, Matt wrote: So, like, keep track of what options the user has selected and add these to an array or something that I can then use to send a $_GET request to my script? Specifically, use them to build a query string (and you can use GET or POST - that's up to you). -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Who needs horror movies when we have Microsoft? -- Christine Comaford, PC Week --~--~-~--~~~---~--~~ 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: Modal Dialog question...
At 10:25 -0800 5/3/09, Daniel Israel wrote: Is there some sort of add-on or control out there that will make a modal dialog? I've got an application where I want a dialog to pop up in the middle of the screen and allow the user to enter/edit data, then do something if the user clicks OK. All the data (to populate the dialog's form) is already in the script, so I don't need to go to the server... Any pointers appreciated... I checked out prototype-UI, but unless I'm missing something, it doesn't exactly do that. All I do, which is nothing specifically to do with prototype, is to have two divs, one which floods the window with an opacity 60% shade (and covers, thus disabling, any existing controls), and another with the dialog, which has a higher z-index. These divs are both hidden until required, then when the user clicks the button, link or whatever, they appear. When the user clicks OK or whatever to dismiss the dialog they're hidden again and the page is back to normal. I've taken to calling this a 'lightbox', and it's a very nice way to get away from popup windows. http://www.londonbusinessforum.com/ - click any of those events, then click the 'Email this to a colleague' link on the right (try emailing it to yourself). Is this what you mean? -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ A professor is one who talks in someone else's sleep. -- W.H. Auden --~--~-~--~~~---~--~~ 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] My first post and an Ajax problem
At 21:17 -0800 18/2/09, T.J. Crowder wrote: You must have checked this, but... Are you _absolutely_ sure that bookFormHandler() is being called at all? It sounds like it's just not hooked up. Hi Yes, I am/was absolutely sure. In my somewhat crude debugging process I'd put a couple of alerts in the function to show me the url and the query string, and they both popped up as expected. Have you walked through the code with Firebug? That I hadn't done, and in fact I haven't got into using Firebug anything like as much as I should, so thanks for the suggestion because... it's fixed! I set the 'Break on all errors' option and it immediately exposed the gremlin. As so often it was a really stupid little thing: I'd changed a relatively unimportant variable (so unimportant that it was one of the things I removed from the code I posted yesterday!) from local to global, but forgotten to remove the 'var' from where it was originally declared. Doh! There was, as I was pretty certain, nothing at all wrong with the basic structure of what I was doing, but because a reference to that variable, immediately before the Ajax.Request call, came up undefined, the rest of the function was broken. Thanks again - I can press on now. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Only two things are infinite, the universe and stupidity - and I'm not sure about the former. -- Albert Einstein --~--~-~--~~~---~--~~ 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] Another Prototype error?
I keep getting a message I don't understand, and I can't even pin down exactly when it's happening. Every now and then Firebug tells me there's 1 error which, when I look at it, says: [Exception... Component returned failure code: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) [nsIRequest.name] nsresult: 0x80004001 (NS_ERROR_NOT_IMPLEMENTED) location: JS frame :: file:///[path to where my Firefox is]/Firefox.app/Contents/MacOS/components/nsLoginManager.js :: anonymous :: line 282 data: no] (aRequest ? aRequest.name : (null)) + It appears not to have any adverse effect on the operation of what I'm doing - should I be concerned about this or just go on ignoring it as I have been? :-) -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ It's better to have something to remember than nothing to regret -- Frank Zappa --~--~-~--~~~---~--~~ 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] Another Prototype error?
At 11:36 -0500 19/2/09, Jason Frisvold wrote: Do you have any other tabs open, or maybe some extensions that gather remote info? Firebug console reports errors for other scripts in other tabs as well.. Might not even be related to what you're working on . Hmmm. Not sure about this. I'll have to try and keep a closer eye on it! -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ Star Wars won't work. -- Frank Zappa --~--~-~--~~~---~--~~ 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] Another Prototype error?
At 11:36 -0500 19/2/09, Jason Frisvold wrote: Do you have any other tabs open, or maybe some extensions that gather remote info? Firebug console reports errors for other scripts in other tabs as well.. Might not even be related to what you're working on . Hi Jason I've tracked down exactly when this is happening now, and I understand why I hadn't been noticing it until after the event, as it were. If I run a script with an Ajax call, then use the WebDeveloper extension's 'View Generated Source', /that's/ when it happens. I guess it's something to do with not being able to run the Ajax request again or something - a good thing it doesn't actually! And the reason I hadn't been noticing it straight away is that when I view the source my eyes are looking at the source window, so I don't notice the error in the main window until I look back there. -- Cheers... Chris Highway 57 Web Development -- http://highway57.co.uk/ It is bad luck to be superstitious. -- Andrew Mathis --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---