Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

full example app

  • Loading branch information...
commit 421c518e64ff0d0eaec462b8b349568ca0a16f96 1 parent cbb9581
Luke van der Hoeven authored
16 app.rb
View
@@ -1,9 +1,21 @@
require 'sinatra'
-get '/iframe_content' do
- erb :iframe_content
+get '/iframe_content_borked' do
+ erb :iframe_content_borked
+end
+
+get '/iframe_content_fixed' do
+ erb :iframe_content_fixed
end
get '/' do
erb :index
end
+
+get '/broken' do
+ erb :index
+end
+
+get '/fixed' do
+ erb :index_working
+end
5 public/basic.js
View
@@ -9,7 +9,10 @@ crunch.pubsub.unsubscribe = crunch.pubsub.unbind;
$(function() {
$('.replace-it').click(function() {
- $('iframe')[0].contentWindow.location.reload();
+ var iframe = $('iframe').first();
+
+ // reloads the iframe content
+ iframe.attr('src', iframe.attr('src'));
});
$('.send-it').click(function() {
9 public/iframe.js
View
@@ -1,12 +1,5 @@
$(function() {
- var test = function(msg) {
+ parent.crunch.pubsub.subscribe('MSG', function(msg) {
console.log('IFRAME', msg);
- }
-
- parent.crunch.pubsub.subscribe('MSG', test);
-
-
- $(window).bind('beforeunload', function() {
- parent.crunch.pubsub.unsubscribe();
});
})
0  views/iframe_content.erb → views/iframe_content_borked.erb
View
File renamed without changes
20 views/iframe_content_fixed.erb
View
@@ -0,0 +1,20 @@
+<!doctype html>
+<html>
+<head>
+ <title>Iframe</title>
+ <script type="text/javascript" src="jquery.js"></script>
+ <script type="text/javascript" src="underscore-min.js"></script>
+ <script type="text/javascript" src="backbone-min.js"></script>
+ <script type="text/javascript" src="basic.js"></script>
+
+ <script type="text/javascript" src="iframe_fixed.js"></script>
+</head>
+<body>
+
+<h1>Iframe Working!</h1>
+
+<p>What can I say? Nothing to see here.</p>
+
+<a href="#send" class="send-it">Send It!</a>
+
+</body>
11 views/index.erb
View
@@ -8,11 +8,18 @@
<script type="text/javascript" src="basic.js"></script>
</head>
<body>
-<h1>Main Page</h1>
+<h1>Broken Example</h1>
+<hr/>
+<a href="/fixed">Working Example</a>
-<iframe src="/iframe_content"></iframe>
+<br/><br/>
+
+<iframe src="/iframe_content_borked"></iframe>
<br/>
<a href="#close" class="replace-it">Clear Out / Refresh</a>
<a href="#close" class="send-it">Send</a>
+
+
+
</body>
23 views/index_working.erb
View
@@ -0,0 +1,23 @@
+<!doctype html>
+<html>
+<head>
+ <title>Main</title>
+ <script type="text/javascript" src="jquery.js"></script>
+ <script type="text/javascript" src="underscore-min.js"></script>
+ <script type="text/javascript" src="backbone-min.js"></script>
+ <script type="text/javascript" src="basic.js"></script>
+</head>
+<body>
+<h1>Fixed Example</h1>
+<hr/>
+<a href="/broken">Broken Example</a>
+
+<br/><br/>
+
+<iframe src="/iframe_content_fixed"></iframe>
+<br/>
+
+<a href="#close" class="replace-it">Clear Out / Refresh</a>
+<a href="#close" class="send-it">Send</a>
+
+</body>
Please sign in to comment.
Something went wrong with that request. Please try again.