[Proto-Scripty] Re: Using a prototype function in dynamic content.
Ah, now, that's interesting. I did try to use evalScripts, but I couldn't find any clear examples of how or where to apply it. I tried putting it in the places it seemed logical, but without effect. So, ok, I have an HTML page includes an onclick to fetch some content which will include scripts. The JS functions to handle this are in an external file. Do I put the evalScripts() in onclick="getStuff(param, param).evalScipts(); or do I apply it to the returned text before putting it in innerHTML like var thereturn = http_request.responseText.evalScripts(); document.getElementById(div).innerHTML = thereturn; I tried both, but couldn't get either to work. C On 31 July, 11:13, "T.J. Crowder" wrote: > Hi, > > You're using the evalScripts option in your ajax call? Can you > produce a small, self-contained example[1]? > > [1]http://proto-scripty.wikidot.com/self-contained-test-page > > -- T.J. :-) > > On Jul 31, 1:22 am, Drum wrote: > > > > > P.S. I tried with both delete eds[id]; and eds[id] = undefined. --~--~-~--~~~---~--~~ 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] how can i implement rails' link_to_remote :submit options using Ajax.updater?
Hello. <%= link_to_remote 'click here', :update=>'some_div', :url=> {:action=>'some'}, :submit=>'group' %> is what I want to implement using Ajax.updater. To do this I coded ( it is invoked when I clicked some link or button, whatever ) new Ajax.Updater('some_div', url(:action=>'some'), { parameters: $('group').serialize(true), method: 'get'} ); group div looks like below: <%= radio_button_tag(:myvalue, 1 %> <%= radio_button_tag(:myvalue, 2 %> on the controller's 'some' looks like below def some if params[:myvalue] == blah blah end if i use link_to_remote with submit options, it worked properly. but in case of my code using Ajax.updater, params[:myvalue] is not set properly. What's wrong with me? Somebody help me. 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: Escaping Input
Hi, I'm surprised by the POST data you quoted, but it doesn't matter, I'm pretty sure I know what's wrong. I was hurrying too much when posting my reply. You don't have to URL- encode the JSON string if you're going to give Ajax.Request a parameters *object* rather than parameters *string*, because Prototype will do it for you -- which is half the point of using an object. So drop the encodeURIComponent bit: // Using an object: entry = Object.toJSON($('busCalForm').serialize(true)); new Ajax.Request( "modules/buscal/processes/saveBooking.php", { parameters: { year: year, recnum: busmstr_id, json: entry }, onSuccess: busCal.gotEntry.bind(this), onFailure: busCal.gotFailure.bind(this) }); // Using a string (not recommended, data gets transformed to an object // and then back again -- but it demonstrates using the // encodeURIComponent function entry = Object.toJSON($('busCalForm').serialize(true)); new Ajax.Request( "modules/buscal/processes/saveBooking.php", { parameters: "year=" + encodeURIComponent(year) + "&recnum=" + encodeURIComponent(busmstr_id) + "&json=" + encodeURIComponent(entry), onSuccess: busCal.gotEntry.bind(this), onFailure: busCal.gotFailure.bind(this) }); Note that I'm escaping all of the components, although if you *know* year and busmstr_id won't include any characters that are special in URLs, you can skip it. Again, though, best to use the object feature of Ajax.Request and let it handle URL-encoding. Sorry for the bum steer earlier, rushing too much. "Do less, better" should be my motto. ;-) -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jul 31, 5:49 pm, infringer wrote: > This method works well in FF 3.5, but FF 3.0.12 doesn't like it... I > really would like to keep the from coming in a separate variable, but > realize I may have to change that. > > 3.0.12's POST (truncated) just for info: > %7Bstartdate%3A%202009-04-23%2C%20 > > 3.5's POST (truncated): > %7B%22startdate%22%3A%20%222009-04-23%22%2C% > > As you can see 3.5 has extra characters... > > I'm sending this to PHP, and my processing script receives the JSON > variable as such > > $json_string = (isset($_POST['json']) ? rawurldecode($_POST['json']) : > ""); > $json = json_decode($json_string, true); > if (($json == '') || empty($json) || ($json == null)) { > $result['valid_result'] = 2; > $result['reason'] = rawurlencode("Unknown error, Administrator has > been notified. Please try again later"); > $result = json_encode($result); > header("Content-Type: application/json"); > print $result; > exit(0); > > } > > so when users are using 3.0.xx they always receive this error message, > because the PHP script doesn't see it as valid JSON. > > but 3.5 users (myself only) can perform the saves/deletes, etc > > This is for an internal application, we only allow FF to be used. > > Thanks for the help! > -David > > On Jul 30, 4:00 pm, "T.J. Crowder" wrote: > > > > > Sorry, I got my wires crossed half-way through the first one of > > those. You can't use String#toJSON, it's not a string! Doh. > > Correcting my first example: > > > entry = encodeURIComponent(Object.toJSON($('busCalForm').serialize > > (true))); > > new Ajax.Request( > > "modules/buscal/processes/saveBooking.php", { > > parameters: { > > year: year, > > recnum: busmstr_id, > > json: entry > > }, > > onSuccess: busCal.gotEntry.bind(this), > > onFailure: busCal.gotFailure.bind(this) > > > }); > > > Sorry 'bout that. > > > -- T.J. :-) > > > On Jul 30, 8:55 pm, "T.J. Crowder" wrote: > > > > Hi, > > > > You're sending an unencoded string (which happens to be in JSON > > > format) as part of your parameters string, which is meant to be URL- > > > encoded data. A # sign is the least of your problems. ;-) You'll > > > want to encode that with JavaScript's encodeURIComponent function[1]. > > > > Somewhat OT, but as of 1.6 (at least), the preferred way to provide > > > options to Ajax.Request is as an object. If you give it a string, > > > that string will be converted to an object, and then later converted > > > back into a string. Yes, really. :-) Also, String has a toJSON > > > function you can use instead of JSON.stringify (not that it matters). > > > > So: > > > > entry = encodeURIComponent($('busCalForm').serialize(true).toJSON()); > > > new Ajax.Request( > > > "modules/buscal/processes/saveBooking.php", { > > > parameters: { > > > year: year, > > > recnum: busmstr_id, > > > json: entry > > > }, > > > onSuccess: busCal.gotEntry.bind(this), > > > onFailure: busCal.gotFailure.bind(this) > > > > }); > > > > How can I effectively escape an entire form, without > > > > having to get the value and escape them individually? Is there a > > > > command I'm missing? > > > > That's not
[Proto-Scripty] Re: IE, attachEvent to div
Hi Jake, I know you said to cancel your post (it had already been posted), so you're not expecting an answer, but: > element = Element('div') // Doesn't work when created this way. It's "new Element(...)", not "Element(...)". (See [1], scroll down to "Element as a constructor"). > element.attachEvent('onclick', function(evt) {alert('hello')} ); // If you're using Prototype, why not use Prototype?[2] [1] http://prototypejs.org/api/element [2] http://prototypejs.org/api/element/observe FWIW, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jul 31, 7:56 pm, Jake wrote: > I am using prototype 1.6.0.3 and IE8. Although I think the same > problem occurred in IE7. Why do the following lines of code give > errors? > > > element = Element('div') // Doesn't work when created this way. > element.attachEvent('onclick', function(evt) {alert('hello')} ); // > can't attach event. > > > This doesn't work either: > > > element = Element('div') > Event.observe(element, 'click', function(evt) {alert('hello')}); > > > However, when I do not use prototype to create the div element, both > of these do not generate errors: > > > element = document.createElement('div'); > element.attachEvent('onclick', function(evt) {alert('hello')} ); > > > > element = document.createElement('div'); > Event.observe(element, 'click', function(evt) {alert('hello')}); > > > I was thinking that a div created with > element = Element('div') > can do everything that a div created with > element = document.createElement('div'); > can do, but it will not allow me to attach an event for some reason. > > Any ideas as far as why the first two don't work? > > 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] Simple Yes/No prompt inside a layer with timeout
I'm looking for a simple (Yes/NO) prompt with a timeout and fade away function so it can "live" on the screen, accept "Y" or "N" or enter or escape, with "N" as the default, and Escape as cancel. It should live within a layer and disappear after a set number of seconds. Any leads? Steve Moyer http://nodes.net --~--~-~--~~~---~--~~ 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] cancel post
Hi, Cancel my last post please. 1.6.0.3 solves my problem. Thought that's what I was using, but guess I wasn't --~--~-~--~~~---~--~~ 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] IE, attachEvent to div
I am using prototype 1.6.0.3 and IE8. Although I think the same problem occurred in IE7. Why do the following lines of code give errors? element = Element('div') // Doesn't work when created this way. element.attachEvent('onclick', function(evt) {alert('hello')} ); // can't attach event. This doesn't work either: element = Element('div') Event.observe(element, 'click', function(evt) {alert('hello')}); However, when I do not use prototype to create the div element, both of these do not generate errors: element = document.createElement('div'); element.attachEvent('onclick', function(evt) {alert('hello')} ); element = document.createElement('div'); Event.observe(element, 'click', function(evt) {alert('hello')}); I was thinking that a div created with element = Element('div') can do everything that a div created with element = document.createElement('div'); can do, but it will not allow me to attach an event for some reason. Any ideas as far as why the first two don't work? 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 -~--~~~~--~~--~--~---