[Proto-Scripty] Re: Scriptaculous 1.8.2 not loading library files
I'm sorry to re-open this thread, but no-one has told me anything about it. Does anyone use Google Ajax Loader API with Prototype Scriptaculous? Have you got the same problem? How can I solve it? Thank you in advance. On 1 dic, 17:18, Alejo [EMAIL PROTECTED] wrote: I also have the same problem, but I use Google Ajax API Loader, so I don't know if the loader puts the javascript files in the head or somewhere else. How can I solve this problem?? Thank you in advance. On 1 dic, 09:27, joe.roback [EMAIL PROTECTED] wrote: So, why can't your scripts be in the head? Do you know you can add scripts to the head dynamically? Like this: for example, pixelpost photoblog, you want to only load these in the image_template.html, and have a header.html+footer.html defined, the scripts will have to go in the body. I also found issues with xhtml1.1 and the DOM. Had to use these insteaad function createElement(element) { if (typeof document.createElementNS != 'undefined') { return document.createElementNS('http://www.w3.org/1999/xhtml', element); } else if (typeof document.createElement != 'undefined') { return document.createElement(element); } return false; } function setAttribute(element, name, value) { if (typeof element.setAttributeNS != 'undefined') { return element.setAttributeNS('http://www.w3.org/1999/xhtml', name, value); } else if (typeof element.setAttribute != 'undefined') { return element.setAttribute(name, value); } return false; } --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: hints appreciated
Hi, The typical approach would be to have a function that does whatever work you want to do when the option's value is changed, and separately have an event handler that calls that function with the appropriate checkbox at appropriate times. In your dom:loaded function, you can locate the checkboxes that are already selected and call your function directly. Here's an example: (More easily viewed on Pastie: http://pastie.org/334728) * * * * !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head titleCheckboxes/title style type=text/css #log p { margin: 0px; } /style script type=text/javascript src='libs/prototype.js'/script script type=text/javascript function init() { var options; options = $$('.option'); options.each(function(opt) { if (opt.checked) { setUpOption(opt); } }); options.invoke('observe', 'click', optionClicked); } function optionClicked(event) { setUpOption(event.findElement()); } function setUpOption(opt) { log(Setting up for option + opt.id + , value = + opt.checked); } function log(msg) { var p; p = new Element('p'); p.update(msg); $('log').appendChild(p); } document.observe('dom:loaded', init); /script /head body form id='theForm' input type='checkbox' class='option' id='check1' value='1' checkedlabel for='check1'Checkbox 1/label brinput type='checkbox' class='option' id='check2' value='1'label for='check2'Checkbox 2/label /form div id='log'/div /body /html * * * * In that example, since I already have an array of the checkboxes (since we're about to invoke 'observe' on them), I just used Enumerable#each to loop through and call my worker function for the ones that are checked. The event handler (I just used the one, click, but obviously you'll want to use whatever) calls the worker function when the box is clicked. Since 'check1' is checked on load, we see a message from setUpOption for it when the page loads; we then see another message from it whenever the box is clicked. HTH, -- T.J. Crowder tj / crowder software / com On Dec 8, 5:42 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am new to prototype, so I guess this must be a common question. It is difficult to explain and also difficult to search for. I start with the code - it should later become a javascript shopping cart: function purchase() { // get product var product = products.get(this.identify().sub('purchase', '')); if (this.checked) { cart.addProduct(product); Element.addClassName('purchase' + product.getCategory() + 'Area', 'areaGreen'); } else { cart.removeProduct(product); var removeAreaGreen = true; cart.getProducts().each(function(pair) { if (pair.value.getCategory() == product.getCategory()) { removeAreaGreen = false; } }); if (removeAreaGreen) Element.removeClassName('purchase' + product.getCategory() + 'Area', 'areaGreen'); } cart.refresh(); } function selectOption() { // get product var product = products.get(this.identify().sub('purchase', '').sub ('Options', '')); product.setActiveOption($(this.identify()).value); cart.refresh(); } // when the dom is fully loaded, execute these scripts document.observe(dom:loaded, function() { // initializing options // todo: find a way to init options and products // add event handlers $$('.modulePurchase .options').invoke('observe', 'change', selectOption).invoke('observe', 'keyup', selectOption); $$('.modulePurchase .purchase').invoke('observe', 'click', purchase); }); This works great so far. Elements with ('.modulePurchase .purchase') are simple checkbox input fields. Elements with ('.modulePurchase .options') are select boxes. My requirement now is that some of the elements are already checked during start of the page. So I want that the functions purchase and selectOptions should be called on any of the mentioned elements during start up of the page. The problem is there is no onload-Event for input fields. Also it is not possible to fire
[Proto-Scripty] Re: Refrence to returned hash values
Hi, Apologies in advance if I've misunderstood. How do I reference these returned hash values? But it's no longer a Hash. You've converted it to a string using Hash#toJSON[1]. If you want it to be a Hash, don't convert it to a string. Change this: return $H({x: w, y: h}).toJSON(); to: return $H({x: w, y: h}); ...and then you can use the values via Hash#get[2], e.g., fb.offSet.get ('x'). But taking things further: Why make it a Hash? Why not just use a POJO? (Plain Old JavaScript Object) If you make that line: return {x: w, y: h}; ...then you can use the properties directly (fb.offSet.x) the way you tried to initially. [1] http://www.prototypejs.org/api/hash/tojson [2] http://www.prototypejs.org/api/hash/get HTH, -- T.J. Crowder tj / crowder software / com On Dec 8, 4:10 pm, Techno~ [EMAIL PROTECTED] wrote: I am trying to access a value that is returned via the $H.toJSON method. However, my alerts keeps saying that it is undefined. Any pointers gratefully received code var Feedback = Class.create({ initialize: function() { this.offSet = this.getOffsets(); }, getOffsets: function() { if (window.innerHeight) { h = window.innerWidth; w = window.innerHeight; } else if (document.documentElement document.documentElement.clientHeight) { h = document.documentElement.clientWidth; w = document.documentElement.clientHeight; } else if (document.body) { h = document.body.clientWidth; w = document.body.clientHeight; } return $H({x: w, y: h}).toJSON(); }}) end code === mark-up snippet === script type=text/javascript var fb = new Feedback; /script body onload=alert(fb.offSet.x) === mark-up end === if I alert(fb.offSet) I receive {x:878,y:1563} I have tried multiple variations: fb.offSet[0].x fb.offSet[x] fb.offSet[0][x] fb.offSet.x[0] fb.offSet[0].x[0] Some just error out some returned undefined. How do I reference these returned hash values? TIA Techno~ --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: autocomplete variant
On Dec 8, 9:30 pm, macsig [EMAIL PROTECTED] wrote: Hello, I have an issue with Ajax.updater. Since I'm a prototype newbie I guess it is something easily solvable. Basically I don't understand what I have to put as url. In any example I can find on prototype website they show '/some_url' without specifying its meaning. The url is entirely up to you. It is the URL of the script that you write to be the Ajax backend: you can call it what you like, and put it where you like (though it introduces many problems if it isn't on the same domain as the script it's being called from). Since my app is a Rails one I tried to create a partial (list_item) with the list item and I passed it as a url but I get Couldn't find Person with ID=list_item If I remove the url parameter I get ActionController::MethodNotAllowed Only get, put e delete requests are allowed. even if I specify get as a method. I don't know Rails, but if it's anything like symfony, a partial isn't enough: it needs to be its own page, which will parse the arguments from the query string, generate the output, and send it with the proper headers. It could be bare text, XML, HTML or it could be empty and return the data in an X-JSON heaader. But if you're going to use Ajax.Updater, you need to return an HTML fragment (not a whole HTML page). In any case, though, it needs to have suitable HTTP headers. I'm guessing that Rails has a way of creating a page which only returns the headers and text you want. 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: hints appreciated
Thanks alot. I could change my code so it is working now! I only didn't want to write an extra function for the event handling: So I included if (element instanceof Event) { element = element.findElement(); } in my functions. Now I can call the functions with an event or with an element. On 9 Dez., 10:26, T.J. Crowder [EMAIL PROTECTED] wrote: Hi, The typical approach would be to have a function that does whatever work you want to do when the option's value is changed, and separately have an event handler that calls that function with the appropriate checkbox at appropriate times. In your dom:loaded function, you can locate the checkboxes that are already selected and call your function directly. Here's an example: (More easily viewed on Pastie:http://pastie.org/334728) * * * * !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; xml:lang=en lang=en head titleCheckboxes/title style type=text/css #log p { margin: 0px;} /style script type=text/javascript src='libs/prototype.js'/script script type=text/javascript function init() { var options; options = $$('.option'); options.each(function(opt) { if (opt.checked) { setUpOption(opt); } }); options.invoke('observe', 'click', optionClicked); } function optionClicked(event) { setUpOption(event.findElement()); } function setUpOption(opt) { log(Setting up for option + opt.id + , value = + opt.checked);} function log(msg) { var p; p = new Element('p'); p.update(msg); $('log').appendChild(p);} document.observe('dom:loaded', init); /script /head body form id='theForm' input type='checkbox' class='option' id='check1' value='1' checkedlabel for='check1'Checkbox 1/label brinput type='checkbox' class='option' id='check2' value='1'label for='check2'Checkbox 2/label /form div id='log'/div /body /html * * * * In that example, since I already have an array of the checkboxes (since we're about to invoke 'observe' on them), I just used Enumerable#each to loop through and call my worker function for the ones that are checked. The event handler (I just used the one, click, but obviously you'll want to use whatever) calls the worker function when the box is clicked. Since 'check1' is checked on load, we see a message from setUpOption for it when the page loads; we then see another message from it whenever the box is clicked. HTH, -- T.J. Crowder tj / crowder software / com On Dec 8, 5:42 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I am new to prototype, so I guess this must be a common question. It is difficult to explain and also difficult to search for. I start with the code - it should later become a javascript shopping cart: function purchase() { // get product var product = products.get(this.identify().sub('purchase', '')); if (this.checked) { cart.addProduct(product); Element.addClassName('purchase' + product.getCategory() + 'Area', 'areaGreen'); } else { cart.removeProduct(product); var removeAreaGreen = true; cart.getProducts().each(function(pair) { if (pair.value.getCategory() == product.getCategory()) { removeAreaGreen = false; } }); if (removeAreaGreen) Element.removeClassName('purchase' + product.getCategory() + 'Area', 'areaGreen'); } cart.refresh(); } function selectOption() { // get product var product = products.get(this.identify().sub('purchase', '').sub ('Options', '')); product.setActiveOption($(this.identify()).value); cart.refresh(); } // when the dom is fully loaded, execute these scripts document.observe(dom:loaded, function() { // initializing options // todo: find a way to init options and products // add event handlers $$('.modulePurchase .options').invoke('observe', 'change', selectOption).invoke('observe', 'keyup', selectOption); $$('.modulePurchase .purchase').invoke('observe', 'click', purchase); }); This works great so far.
[Proto-Scripty] Re: Ajax.InPlaceEditor value needs to be part of the URL
On the CodeIgniter side, I think you will need to step outside of CI's routing in order to do this. I know it's possible to mix and match CI routing and traditional GET requests in the same application -- it's just a matter of knowing what all you will need to pass to the application. Try reading through the source in the router and see what variables it expects. In my own framework (heavily influenced by CI and Rails) I need to see model=fooaction=barid=123, so if you pass all that as a querystring request to routing.php, you get a page, same as if you went to mysite.com/foo/bar/123. On the IPE side, you can modify the name of the fields sent to the server through the POST request by means of the callback option in the parameters. Further, you can modify the underlying Ajax call (change it to GET, maybe?) using the ajaxOptions parameter. Have a read on the wiki: http://github.com/madrobby/scriptaculous/wikis/ajax-inplaceeditor Walter On Dec 8, 2008, at 3:04 PM, Russell wrote: I am using the CodeIgniter framework for PHP and need the value from my InPlaceEditor to pass as a straight value (i.e. /something) instaed of the way it does now (?value=something) script type=text/javascript var editor = new Ajax.InPlaceEditor('user?=$i?', '/index.php/app/ updateUserJob.php/?=$data[$i]-empNum?/'); /script my url now is '/index.php/app/updateUserJob.php/123456/? value=something and I need it to be '/index.php/app/updateUserJob.php/123456/something is this possible? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Submit a form using enter
I am having trouble writing a function that will allow users to submit a form that is in a modal popup using the enter key in IE6. It works in all other browsers. I was thinking something along the lines of this: $('form_submit').onkeydown=if(event.keyCode==13){this.form.submit ();return false;}; but this doesnt seem to work...Does anyone have any ideas? --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---