2011-10-04 6 views
1

CFM과는 cfform 값을 변경동적 바인딩 출력을위한 자바 스크립트

<html> 
<head> 
<title>Test Page</title> 
<script type="text/javascript"> 
    function toggleV(value){ 
     document.getElementById('blah').value = value; 
    } 
</script> 
</head> 
<body> 
<cfform name="coolfrm"> 
    <cfinput type="hidden" name="blah" id="blah" value="default"> 
    <a onclick="toggleV('anothervalue')" style="cursor:pointer;">click Me</a> 
</cfform> 

<cfdiv bind="cfc:TestCFC.func({coolfrm:blah})"></cfdiv> 

</body> 
</html> 

CFC

<cfcomponent> 
    <cfscript> 
     remote function func(simpleString){ 
      return simpleString; 
     } 
    </cfscript> 
</cfcomponent> 

내가 할 수있는이 코드는 "기본"에서 cfdiv의 텍스트를 변경할 수 있습니다 기대에 "anotherValue라는" .

이것은 내가 생각하는대로 작동하지 않으며, 왜 그런지 알고 싶습니다. 의 정의에 의해

답변

2

: 제어 입력 포커스를 잃고 그 포커스 값을 획득 한 이후 수정되었을 때 http://www.w3.org/TR/html4/interact/scripts.html

onchange를 이벤트가 발생한다.

필드를 프로그래밍 방식으로 수정하면 변경 이벤트가 제대로 발생하지 않습니다.

약간 자바 스크립트 기능을 변경하여이 문제를 해결 :

function toggleV(value){ 
    document.getElementById('blah').value = value; 
    ColdFusion.Event.callBindHandlers('blah',null,'change'); 
} 
+0

이 최고, 그게 내가 찾고 있었던 것입니다. 감사. – John

+0

신용은 CFJediMaster에게 다음과 같이 전달됩니다 : http://www.coldfusionjedi.com/index.cfm/2009/7/8/Forcing-ColdFusion-to-recognize-changes-made-to-data-used-for-Ajax - 바인딩 –

관련 문제