2016-08-04 1 views
-1

프로젝트의 회전 장치에 처음 추가되었습니다. 그녀는 올바르게 표시했습니다. ➢ 다른 페이지에 카드를 추가하면 회전 목마가 무너집니다. 한 페이지와 다른 스크립트에 대해 스크립트를 작동시키는 방법은 무엇입니까?레일. 다른 스크립트의 다른 페이지의 경우

application.js :

//= require jquery 
//= require bootstrap-sprockets 
//= require bootstrap 
//= require jquery_ujs 
//= require jquery.turbolinks 
//= require jquery.validate 
//= require validation 
//= require jquery-1.5.min 
//= require underscore 
//= require gmaps/google 
//= require markerclusterer 
//= require google_maps 
//= require jcarousel 
//= require turbolinks 
//= require_tree . 

$(document).ready(function() { 
    // Initialise the first and second carousel by class selector. 
    // Note that they use both the same configuration options (none in this case). 
    $('.d-carousel .carousel').jcarousel({ 
     scroll: 1 
    }); 

}); 

google_maps.js :

$(function() { 
    handler = Gmaps.build('Google'); 
    handler.buildMap({provider: {scrollwheel: false}, internal: {id: 'map'}}, function() { 
     var ht = 80; 
     var wt = 80; 
     markers = handler.addMarkers([ 
      { 
       "lat": 23.953052, 
       "lng": 56.677616, 
       "picture": { 
        "url": src="../../assets/kafe.png", 
        "width": wt, 
        "height": ht 
       }, 
       "infowindow": "kafe" 
      } 
     ]); 
     handler.bounds.extendWith(markers); 
     handler.fitMapToBounds(); 
    }); 
    google.maps.event.addDomListener(window, "load", initialize); 
}); 

jcarousel.js :

(function ($) { 
     $.jcarousel = function (e, o) { ... })(jQuery); 

답변

0

시도의 remov e

//= require underscore 
//= require gmaps/google 
//= require markerclusterer 

line from application.js 및 google_maps.js에 추가하십시오. 보기에 라인을 추가하십시오. <%= javascript_include_tag "google_maps.js", params[:you_controller] %>. 설정 에서/이니셜/ assets.rb 일 jquery.turbolinks

%w(controller_one controller_two controller_three).each do |controller| 
     Rails.application.config.assets.precompile += ["#{controller}.js.coffee", "#{controller}.css"] 
    end 
    Rails.application.config.assets.precompile += %w(google_maps.js) 

를 추가하고 서버 를 다시 시작하고 확인

관련 문제