prototypejs

AJAX post JSON data from Javascript to Grails

为君一笑 提交于 2020-01-04 01:58:13
问题 I'm trying to POST JSON formatted data from Javascript (using Prototype) to Grails. My Javascript code is: var JSONObject = new Object; JSONObject.id = "23"; JSONObject.name = "Test 1"; JSONstring = JSON.stringify(JSONObject); var url = "${createLink(controller:'testController', action:'receiveJson')}"; new Ajax.Request(url, { method:'post', contentType:'application/json', parameters:JSONstring, asynchronous:true, onSuccess: function (req) { sendInfoResponse(req.responseText); } }); and the

Problems with iframe when used more than once on the page

眉间皱痕 提交于 2020-01-03 10:13:30
问题 I'm creating a quickview functionality, where you can see the contents of each item in a product listing directly in a modal that will open. In the modal there is a frame that is generated dynamically with javascript, and I place the url of my controller that renders the modal content (url like this http://localhost/quickview/product/view/id/18564/ ). When the modal is closed, I delete the modal content, and when the user wants to see the content of another product on the same page, I re

AJAX upload using Prototype.js plugin

倾然丶 夕夏残阳落幕 提交于 2020-01-03 04:19:48
问题 How to upload a image file using ajax by using prototype.js plugin, I need to display those image after it is uploaded please help to solve this problem. Thanks 回答1: You will need something on the server, too. I recommend using paperclip for storing the files on your server. Once you have it set up, you should make your ajax generate one form with a "file" field. Also, remember that the form must be multipart. <% form_for @picture, :html => { :multipart => true } do |f| %> <%= f.file_field

Prototype Element.toggle on hover, disables with childElements

戏子无情 提交于 2020-01-02 08:36:32
问题 I got the following situation: I got a table structure like this: <tr> <td>text</td> <td>text</td> <td>text</td> <td><a href="#"><img src="#" /></td> <td><span style="display:hidden"><a href="#">e</a> <a href="#">e</a></td> </tr> What I'm doing with the following function is displaying the hidden span on hover of the table row. However it quirks whenever I hover the childElements inside the tr: the anchored image and the span itself. How can I fix this? // Reveal item options on hover $$('

Pass in local variable to callback function [duplicate]

青春壹個敷衍的年華 提交于 2020-01-02 00:59:54
问题 This question already has answers here : JavaScript closure inside loops – simple practical example (44 answers) Closed 3 years ago . Question How can a callback function retain a local variable from whence it was created? Simple example I'm creating a video player. It will have sliders to control the saturation, contrast, and hue. When the user plays with the sliders, it needs to acknowledge which slider got changed and what value it got changed to. The problem is that the name of the slider

Binding custom functions to DOM events in prototype?

两盒软妹~` 提交于 2020-01-01 06:30:14
问题 Jquery has a great language construct that looks like this: $(document).ready(function() { $("a").click(function() { alert("Hello world!"); }); }); As you might guess this, once the document has loaded, binds a custom function to the onClick event of all a tags. The question is, how can I achieve this same kind of behavior in Prototype? 回答1: Prototype 1.6 provides the "dom:loaded" event on document: document.observe("dom:loaded", function() { $$('a').each(function(elem) { elem.observe("click"

Prototype - click event by element class name

别说谁变了你拦得住时间么 提交于 2020-01-01 04:24:29
问题 I am new to the prototype framework and am trying something really simple and failing. I am trying to respond to a click event on a button like so: $$('.btn').observe('click', respond); function respond(event) { alert("hello"); } Why isn't this working? Please help! 回答1: Unlike jQuery, handing selectors with multiple results in Prototype works a little differently. You need to handle each selected result separately using .each() . $$('.btn').each(function(element) { element.observe('click',

jRails vs. Prototype

末鹿安然 提交于 2020-01-01 02:52:31
问题 I am not trying to make this a preference question, I am really wondering what people's experiences are with using jQuery and Rails or jRails for development. Most rails users including myself up to now have been using Prototype. However, I am mixing in a lot of jQuery plugins since they are so easy to use and extend. I am now thinking about moving from Prototype to jQuery for a new Rails project. However, I love the Power of Prototype. Protoype is almost a new language that sites ontop of JS

Create event observer for focus?

三世轮回 提交于 2019-12-31 10:39:09
问题 Is it possible to have focus events bubble in protoype? I am trying to prevent having to assign an observer on every input element. <script language="javascript" type="text/javascript"> document.observe('dom:loaded', function() { // Doesn't work $('editForm').observe('focus', function(evnt){ console.log('FOCUS!'); }); // Works $('editForm').select('INPUT').each(function(elem) { elem.observe('focus', function(evnt){ console.log('FOCUS!'); }); }); }); </script> <form method="post" name=

Programmatically manipulating DOM element value doesn't fire onchange event

孤人 提交于 2019-12-31 05:45:09
问题 I've got a hidden form field, and when a button gets pressed the value of the hidden field is changed. Now, I've added an observer to the hidden field, listening for changes to occur. For some reason, though, the event listener never kicks in, even though the value of the hidden element changes. I'm using Prototype and Firefox 3.6. The code looks roughly like this: button.observe('click', function(event) { hiddenField.setValue(someValue); }); hiddenField.observe('change', function(event) {