forked from External/greenlight
Merge pull request #5 from jfederico/master
Encapsulated javascript for landingController
This commit is contained in:
commit
14ad57d4d1
|
@ -1,3 +0,0 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
|
@ -0,0 +1,27 @@
|
|||
(function() {
|
||||
var initIndex = function() {
|
||||
$('#join_form_button').click (function (event) {
|
||||
$.ajax({
|
||||
url : $(this).data ('url') + "?name=" + $('#join_form_name').val(),
|
||||
dataType : "json",
|
||||
async : true,
|
||||
type : 'GET',
|
||||
success : function(data) {
|
||||
$(location).attr("href", data.response.join_url);
|
||||
},
|
||||
error : function(xhr, status, error) {
|
||||
},
|
||||
complete : function(xhr, status) {
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
$(document).on("turbolinks:load", function() {
|
||||
if ($("body[data-controller=landing]").get(0)) {
|
||||
if ($("body[data-action=index]").get(0)) {
|
||||
initIndex();
|
||||
}
|
||||
}
|
||||
});
|
||||
}).call(this);
|
|
@ -45,26 +45,6 @@
|
|||
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(document).ready(function($) {
|
||||
$('#join_form_button').click (function (event) {
|
||||
$.ajax({
|
||||
url : $(this).data ('url') + "?name=" + $('#join_form_name').val(),
|
||||
dataType : "json",
|
||||
async : true,
|
||||
type : 'GET',
|
||||
success : function(data) {
|
||||
$(location).attr("href", data.response.join_url);
|
||||
},
|
||||
error : function(xhr, status, error) {
|
||||
},
|
||||
complete : function(xhr, status) {
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<% if current_user.nil? %>
|
||||
<ul>
|
||||
<li><%= link_to 'Twitter', '/auth/twitter' %></li>
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<body data-controller="<%= params[:controller] %>" data-action="<%= params[:action] %>">
|
||||
<!-- Messages -->
|
||||
<div id='messages' class='hidden'>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue