2013-12-19 4 views
0

나는 유성 서버 설치의 주어진 예를 시험 중이다.이 예제에서는 모든 것이 좋다. 그러나 하나의 새로운 입력 필드를 추가했다. 사용 방법 자바 스크립트에서이 입력 텍스트 값 사용 유성 템플릿 .I 이것에 대해 아무런 생각이 들지 않으므로 도와주세요.Get HTML HTML을 유성을 사용하여 자바 스크립트에 입력

html로 코드 :

<head> 
    <title>myapp</title> 
</head> 

<body> 
    {{> hello}} 
</body> 

<template name="hello"> 
    <h1>Hello World!</h1> 
    {{greeting}} <br> 
    First name: <input type="text" name="firstname"><br> 
    <input type="button" value="Click" /> 
</template> 

JS 코드 : 클라이언트 내부

if (Meteor.isClient) 
{ 
    Template.hello.greeting = function() 
    { 
    return "Welcome to myapp."; 
    }; 



    Template.hello.events 
    ({ 
    'click input' : function() 
    {  
     // template data, if any, is available in 'this' 
     if (typeof console !== 'undefined') 
     console.log("You pressed the button"); 
     alert("firstName="+ //here get input text value); 

    } 
    }); 
} 



if (Meteor.isServer) 
{ 
    Meteor.startup(function() 
    { 
    // code to run on server at startup 
    console.log("Is Running Server"); 
    }); 
} 
+0

잘 작동합니다. js 콘솔에서 "단추를 눌렀습니다"라는 메시지가 표시되지 않습니까? –

+0

이것은 나에게 잘 돌아가며 작동하지 않을 이유가 없습니다. –

+0

그래,하지만 나 한테는 효과가 없어. 내가 할 수있는 실수는 뭐야? – Venkat

답변

0

. false를 반환해야합니다.

Template.hello.events 
    ({ 
    'click input' : function() 
    {  
     console.log("You pressed the button"); 
     return false; 

    } 
    }); 
+0

이것은 실행되지 않습니다. @ pahan. – Venkat

+0

@Venkat이 작업을 수행합니다. 어쩌면 당신은 자바 스크립트 콘솔을보고 있지 않습니다. 대신'message.log'를'alert'으로 변경하십시오. – Akshat

관련 문제