레일스로 돌아가고 있습니다. (몇 년이 지났습니다.) 그래서 저는 간단하게 뭔가를 놓친 것 같습니다. 그것은 또한 내 자바 스크립트가 레일스 내에서 어떻게 작동하는지 이해하지 못할 수도 있습니다.라우팅/자산 파이프 라인 문제 - 정의되지 않은 자바 스크립트 메소드
내 생각에는 (haml에서) 올바르게 설정 한 것 같습니다. 레이아웃에 확실히 포함 된 파일에 자바 스크립트를 추가했습니다. (그리고 CSS가 올바르게 보인다.) 나는 뷰에 연결하는 자바 스크립트 함수 (온라인에서 찾은 슬라이드 쇼)를 얻지 못하고있다. 나는 여기에 내보기의 %body{ :onload => setUpslideShow() }
사용하려고 해요 :
if (! window.CMFuser) { CMFuser = {}; }
$(function() {
var s = CMFuser;
... (edited out to save space) ...
// slideshow
slidePrefix = "slide-";
slideControlPrefix = "slide-control-";
slideHighlightClass = "highlight";
slidesContainerID = "slides";
slidesControlsID = "slides-controls";
setUpSlideShow = function()
{
... lots of code that doesn't get called so I'm leaving it out to save space ...
그리고 여기에 내가 해당 줄 레이아웃에서 생각 내용은 다음과 같습니다 : 여기
%body{ :onload => setUpSlideShow() }
%script{type: 'text/javascript'}
if (! window.CMFmainmenu) { CMFmainmenu = {}; }
var s = CMFmainmenu;
s.user_id = "#{@user.id.to_s}";
s.partial_mainmenu_path = "https://stackoverflow.com/users/" + s.user_id + "/xx/mainmenu";
s.add_new_senior = "#{UsersController::ADD_NEW_SENIOR}"
s.add_new_senior_path = "#{new_seniors_settings_path(@locale,@user,@senior)}"
#mainmenu
... (edited out to save space) ...
#slideshow.greenBorder
#slides
= image_tag '/assets/newlook/div_1_img.png', class: 'slide'
%p
Everyone loves photo albums.
Get your user ready to brag, and
populate and arrange albums by
event, special people, year or any
category you can imagine.
=link_to "Learn how.", ''
= image_tag '/assets/newlook/div_2_img.png', class: 'slide'
%p
If typing is difficult for your
loved one, remove the frustration
of a typed response. They can
respond with a voice message, or
with auto replies that you set up.
=link_to "Learn how.", ''
= image_tag '/assets/newlook/div_3_img.png', class: 'slide'
%p
Arms too short? You can specify
the minimum font size used for
your user's email.
=link_to "Learn how.", ''
#slides-controls
1
2
3
나의 자바 스크립트의 = javascript_include_tag "lib/modernizr-2.0.6.min", "lib/respond.min","application", "users"
여기서 "사용자 "자바 스크립트 파일입니다. %body{ :onload => setUpslideShow() }
을 주석 처리하면 javascript 파일이 html 소스에 나타납니다.
오류의 전체 텍스트 :
NoMethodError in Users#mainmenu
Showing /opt/cmf/app/views/users/mainmenu.html.haml where line #4 raised:
undefined method `setUpSlideShow' for #<#<Class:0x007fe054fa0a28>:0x007fe05594ae20>
Extracted source (around line #4):
2: - # users/mainmenu
3:
4: %body{ :onload => setUpSlideShow() }
감사