Question: I am writing a greasemonkey script. The site is using jquery, i need a function in a newer version. In my GM script i have

```
// @require        http://ajax.microsoft.com/ajax/jQuery/jquery-1.3.2.min.js
...
var $ = unsafeWindow.jQuery;

```

However after using alert($().jquery); i see it is still the old version. How can i get the newer version in code?

Answer: 
You can do it the same way you can have your `create` and `edit` views showing the same form with a partial.

\_tab.html.erb

```
<div class="tab" id="<%= tab.id %>">
   <p>whatever</p>
</div>

```

show.html.erb

```
<%= render 'tab', :tab => TabObject %>

```

show.js.erb

```
$('#tabs.')....
$('something').append("<%= escape_javascript(render('tab', :tab => TabObject)");

```

And if you requesting a page with jQuery's `script` dataType, you really should have corresponding views because while rails will render html views in its place, jQuery will put them inside a `<script>` tag which isn't supposed to have html in it.
Loading JS dynamically can introduce all sorts of complexity that I think is often best avoided. I think it's better to load all of your JS at once in a single file on page load - this way you can have a single minified script request which facilitates caching and performance. 

Creating tabs can then trigger the appropriate code handling. You can start wrapping this into an event model with listeners (so code listens for tabs of the right type to be added), or you can simply call a function once the ajax request to load the has been successfully completed.