I'm trying to do a manual jQuery AJAX request the following way:
$("#user_plan_id").change(function() {
$("#plan_container").load('/plans/' + this.value);
});
I have the "rails.js" file included in my header, and a "<%= csrf_meta_tag %>".
I see from my log that the request IS getting to the server (although without the authentici...
There may be a better way of doing this, but currently I have an nicely encapsulated, JavaScript object which can have some configurable options. I include a chunk of HTML code on a page (via Dreamweaver 'snippets'), and on page load my JS file runs through the DOM and identifies any of those code chunks as a particular functionality, an...
I need to do multiple file uploads using nested form and jQuery. so I wrote an helper using link_to_function method:
def add_document_link(title, form)
link_to_function title do |page|
form.fields_for :documents, Document.new, :child_index => Time.now.to_i do |f|
page << "$('#documents').append('#{escape_javascript(r...
Sorry for the title.....bit difficult to word what I really want to ask.
Some websites allow a user to copy and paste some widget for use with their own site. For example, getsatisfaction. Yes, those feedback icons that I hope most of you see in various places.
If you have a look at twitterfeed, on the left there will be a feedback ico...
As you know, when you upgrade from Rails 2 to 3 you replace this:
link_to_remote "more", :url => {...}
with this:
link_to "more", {...}, :remote => true
But how do you handle the :update option in link_to_remote? In Railscast #205 Ryan Bates demonstrates link_to with :remote and a server response that includes JavaScript code to up...
I have a new application starting that's using Rails 2.3.8 for stability concerns and gem compatibility, however we'd like to begin being conscious of Unobtrusive JavaScript by implementing the Rails 3 style UJS in this application. Is there any existing plugin/gem that backports this feature?
We are currently using the jrails gem to s...
Hi,
in our project currently i have the following problem. I have to bind some clicks to a list of elements locking like the following:
<ul>
<li class="listeelement" id="load-content-id-1"><div>listcontent</div></li>
<li class="listeelement" id="load-content-id-2"><div>listcontent</div></li>
<li class="listeelement" id="...
I'm trying to add the asynchronous version of the Google Analytics tracking code to a website.
I'd like to keep the JavaScript in a separate file, and call it from there.
Here's what I've currently got in my .js file:
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
...
Google hasn't yielded satisfactory results. I'd appreciate it if people can provide some suggestions. Thanks.
...
Given an Array Literal inside a JavaScript Object, accessing its own object's properties does not seem to work:
var closure = {
myPic : document.getElementById('pic1'),
picArray: [this.myPic]
}
alert(closure.picArray[0]); // alerts [undefined]
Whereas declaring an Array Item by accessing an other JavaScrip...
Hello all,
I've been assigned a project to create a js library that serves as a starting template for all of my company's websites. The idea is to include some standard things that we do so that we aren't reinventing the wheel every time.
I've made a good bit of headway thus far, but I cant help but feel like I could be organizing thi...
I want to create an object that is globally accessible after the DOM has loaded. My approach is to use prototypes dom:loaded event and instantiate the Object.
The JavaScript Code:
document.observe("dom:loaded", function() {
var globalPAO = new picArrayObject();
alert(globalPAO.picArray[0]); // alerts [object HTMLDivElement]...
I can't seem to use jQuery Accordions with definition lists that have multiple desciption items (dd). The author's examples have only single dd items.
In the example below B2, B3 & C2 show onLoad, rather than hide like A1, B1 & C1 as I would prefer.
How would I achieve this?
jQuery('dl').accordion({
event: 'click',
activ...
I have adynamic grid, and the functionality of the data in there needs to work such that I can copy down data in my grid incrementally. Assuming in row 5, I enter 10, the following rows starting from the 6th row should read from 11 etc.
If I go to row one which is blank, and enter 2, the count should increment and auto-correct from tha...
Hi guys,
I've got a problem with linking unobtrusive js file with view.
I've got view named index.html.erb
...
<div id="fooBar">say bye!</div>
...
Also I've got js file index.js.erb
$("#fooBar").html("say hello!")
Currently I get say bye message, because javascript file are not executed.
What I'm doing wrong?
It seems to me th...
I am trying to embed a pdf into my webpage using an object that will fallback to an iframe which loads the pdf through an external rendering service for users that do not have acrobat installed.
I am trying to do it like this:
var container = document.createElement("div");
var object = document.createElement("object");
var iframe = doc...
<script type="text/javascript">
alert(new Date(2010,8,31));
alert(new Date(2010,9,1));
</script>
Try the code above. The browser display the same date in both message. Why???
...
Hi,
before rails3 I had a working multiple ajax(mootools) file upload solution.
I used form_to_remote with an iframe and responds_to_parent.
In rails3 the ajax upload with form_tag remote => true, traget => "my_iframe" doesn't work.
The the param[:uploaded_image]with the file is missing.
I don't know why.
Can anyone recommend a good a...
This question is to piggy back off of a previous one I asked yesterday, which deals with moving the create/edit feature of a model onto its index page. One last issue I am having is that I when I go to delete a model, I have some javascript that is supposed to run that reloads the list of models to reflect the change in the database. Thi...
Hi guys at times I return large chunks of HTML in ajax requests. However I notice that they don't come with all the prototype extensions applied to them at all. How can I set up so after an ajax request all my returned code has all the attached functions and properties which prototype applies to all DOM elements upon page load.
...