1 Replies - 2482 Views - Last Post: 23 January 2012 - 02:08 PM Rate Topic: -----

#1 NotarySojac  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 428
  • Joined: 30-September 10

Rails - Manually do <%= javascript_include_tag :defaults %>

Posted 23 January 2012 - 01:12 PM

I started a project kind of a while ago and when I was messing around with the applications layout (which handles the look and feel of all pages for any non-rails ppl looking). I was going through it, and for some reason I didn't like doing <%= javascript_include_tag :defaults %> . I'm not really sure what I was thinking back then but I was doing things like:

        <script type="text/javascript" src="/javascripts/jquery-1.6.2.min.js"></script>
	
	<script type="text/javascript" src="/javascripts/widget-grid.js"></script>
	<%= javascript_include_tag 'users_form' %>



I'm now noticing that those basic scaffolding pages that come with rails have been broken. I tested with a fresh project, and it does indeed seem to break the scaffold pages when <%= javascript_include_tag :defaults %> is commented out.

Here's the thing though, when I try to manually add in the missing javascripts, it doesn't repair the scaffolding pages.

  <script type="text/javascript" src="/javascripts/application.js"></script>
  <script type="text/javascript" src="/javascripts/rails.js"></script>
  <script type="text/javascript" src="/javascripts/controls.js"></script>
  <script type="text/javascript" src="/javascripts/prototype.js"></script>
  <script type="text/javascript" src="/javascripts/dragdrop.js"></script>
  <script type="text/javascript" src="/javascripts/effects.js"></script>



Here's the line of html that doesn't do what it otherwise would do (display a warning prompt, etc):
<a rel="nofollow" data-method="delete" data-confirm="Are you sure?" href="/books/16">Destroy</a>



So what am I missing? I've scanned around the linked javascripts, thinking something in there must be dynamically named, but I can't find anything =/

Is This A Good Question/Topic? 0
  • +

Replies To: Rails - Manually do <%= javascript_include_tag :defaults %>

#2 NotarySojac  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 53
  • View blog
  • Posts: 428
  • Joined: 30-September 10

Re: Rails - Manually do <%= javascript_include_tag :defaults %>

Posted 23 January 2012 - 02:08 PM

I solved my underlying problem which was that apperently in rails 3.0.x projects, rails' own prototype.js library will not work if a jquery library is subsequently loaded. My solution at the moment was to just add:

<head>
<%= javascript_include_tag :defaults %>
</head>



to my actual index.html.erb (which sadly disables jquery I think, but luckily I don't use jquery on any of my scaffolding pages).

I hear jquery is the new prototype in 3.1 (or at least it's js library independent). Hopefully I will get some spare time and be able to upgrade the project to that iteration and benefit in this area cause it feels a little icky to be doing things the way I am now.

This post has been edited by NotarySojac: 23 January 2012 - 02:09 PM

Was This Post Helpful? 1
  • +
  • -

Page 1 of 1