2015-01-22 7 views
0

나는 프로젝트에서 일하고 있는데이 프로젝트에서는 .js 파일 안에 다음 코드가있다.자바 스크립트 함수 내에서 onclick

// continue button (jump to next field) 
    this.ctrlContinue = createElement('button', { cName : 'fs-continue', inner : 'Continue', appendTo : this.ctrls }); 
    this._showCtrl(this.ctrlContinue); 

위의 코드에 onclick="setBrowserFrameSource(); return false;"을 추가해야합니다. 나는 시도했다 :

cName : 'fs-continue' . 'onclick="setBrowserFrameSource(); return false;"', 그러나 이것은 효과가 없었다!

도와 주셔서 감사합니다. 여기

의견에 질문으로 좀 더 코드 : Rafail Akhmetshin에서 대답

/** 
* addControls function 
* create and insert the structure for the controls 
*/ 
FForm.prototype._addControls = function() { 
    // main controls wrapper 
    this.ctrls = createElement('div', { cName : 'fs-controls', appendTo : this.el }); 

덕분에 나는 다음에 코드를 변경 :

 this.ctrlContinue = createElement('button', { cName : 'fs-continue', inner : 'Continue', appendTo : this.ctrls }); 
    this.ctrlContinue.onclick = function() { 
     console.log('test'); 
    };  
    this._showCtrl(this.ctrlContinue); 

이제 내 본능은 내가 필요로 말한다 이걸로 무언가를 할 수 console.log('test'); 하지만 뭐라구? 이 코드를 setBrowserFrameSource(); return false;으로 변경해야합니까, 아니면 코드를 원래 기능에 추가해야합니까?

도움을 주신 모든 분들께 감사드립니다.

+2

하는 데 도움이 시도? – tymeJV

+1

은'createElement' 함수 코드를 제공합니다 –

+1

프로젝트에서 사용되는 JavaScript 프레임 워크는 무엇입니까? 나는'cName : 'fsContinue', onclick : '...','(쉼표, 점이 아님)을 시도 할 것입니다. – phadej

답변

4

this.ctrlContinue.onclick = function() { 
    // your code here. 
}; 

희망 같은 것을이`createElement` 무엇

+1

감사합니다. 난 당신의 코드를 구현하는 방법을 모르는 한 가지 문제가 있습니다. 그것은 나를 위해 모두 새로운 것입니다. – purple11111

+1

요소를 작성한 후에 입력하십시오. 'createElement()'가 –

+1

'\t \t this.ctrlContinue = createElement ('버튼', {cName : 'fs-continue', 내부 : '계속', appendTo : this.ctrls})라고 불리는 후; \t \t this.ctrlContinue.onclick = function() { \t \t console.log ('test'); \t \t}; \t \t \t \t this._showCtrl (this.ctrlContinue)' 나는 – purple11111

관련 문제