메신저 새롭다 Javascript와 Rails 3.1. 그래서 지금은 레일 응용 프로그램까지 싶게 runnig와 내가 whant 일을 가지고 있지만 : 나는 내가이 태그를 포함 jave jQuery를/커피 스크립트rail3.1 javascript coffecsript newbie 질문
로 (등등 좋은 드롭 다운 메뉴 추천하고) 어떤 아이 캔디를 추가하고 싶었, application.js에는 자체 작성된 메소드/함수가 포함되어 있습니다. 하지만 일부 불필요한 동작이 발생합니다. id가 pages.js.coffee에 alert()를 추가했으며 pages_controller에서 무언가를 호출 할 때만 실행되기를 바래요.하지만 모든 페이지에서 호출됩니다. 왜 그런가요? 둘째 나는이 같은 <h1>
태그를 착색 작은 테스트 기능을 추가 :
app/assets/javascript/pages.coffee.js:
highlight_h1 = (color) ->
$('h1').css('background',color)
#change colour on page load
$ -> highlight_h1 "red"
#add some click action for fun
$('#ccolor').click ->
highlight_h1 "blue"
$('button').click ->
highlight_h1 "yellow"
는 이제
<h1>
페이지로드에 빨간색 배경을 얻을. 하지만 내 클릭 액션 중 아무 것도 작동하지 않는 것 같습니다. 나는 무엇인가 놓쳤는가? 여기 렌더링 된 html이 있습니다 :
<h1 id="ccolor" style="background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: red; background-position: initial initial; background-repeat: initial initial; ">Home</h1>
<p>Here Should be a Login Page an Stuff</p>
<button>make me yellow</button>
<a href="https://stackoverflow.com/users/sign_up" class="signup_button_round">Sign up now!</a>
어떤 힌트가 있습니까?
덕분에 도움이 ... 내게 부끄러운 줄 알았어 마지막 달 Python 프로그래밍했다 .... 어떤 의도에 대해 까다 롭습니다 –