jquery cfml trigger('change') not working

ぐ巨炮叔叔 提交于 2019-12-31 03:34:06

问题


What I need is a cfselect bound to a query that lists file types, a cfdiv that lists the saved files, and a button that scans an image to be saved as a pdf file with the name prefixed by the value of the input field.

Simple page.

<cfselect name="DocType" id="DocType" class="selectClass" query="qGetDocTypes" display="name" value="DocTypeID">
<input name="ScanDocument" id="ScanDocument" type="text" value="" class="ScanDocument">

<cfdiv id="handler_#docAreaID#" bind="url:#request.controlurl#documentHandler/?docareaID=#docareaID#&variableID=#variableID#&Fav=#attributes.Fav#&userid=#attributes.userid#&showform=1&ScannedDocument={ScanDocument@change}">




// remove blanks from text
ScanDoc1 = $('input.scandocument').val();
ScanDoc = ScanDoc1.replace(/\s/g, '');
<cfoutput>
ColdFusion.navigate('url:#request.controlurl#documentHandler/?docareaID=#docareaID#&variableID=#variableID#&Fav=#attributes.Fav#&userid=#attributes.userid#&showform=1&ScannedDocument='+ScanDoc);
</cfoutput>

The coldFusion.Navigate does NOT refresh the CFdiv, and it also trigger an event for onBrowseAway I use for the main form action. I can simulate the div refresh by manually changing the value of the input but it will be hidden after I get this to work.


回答1:


Let me preface this by stating that I have not used the ColdFusion.navigate functionality before but according to the documentation here the function needs to be a link target. It needs to be in the href portion of an a tag. Look at the example on the documentation page that I referenced. So try adding your code to an a tag like this:

<cfoutput>
<a href="javascript:ColdFusion.navigate('#request.controlurl#documentHandler/?docareaID=#docareaID#&variableID=#variableID#&Fav=#attributes.Fav#&userid=#attributes.userid#&showform=1&ScannedDocument='+ScanDoc,'handler_#docAreaID#');">click here</a>
</cfoutput>

Notice that I removed the url: text from your code. That does not appear to be necessary.

It also appeared as though you are missing the container parameter for the function. The documentation states that if you are missing this parameter the link will be treated as a normal URL and the entire page will be refreshed. (Although your code was not a link?)

Also, I'm not sure if you can reference the ColdFusion variables in the URL of the function like you are. Those are server-side and this function is client-side (javascript). Like I said, I have never used this before but these are my thoughts after reading that documentation.




回答2:


$('input.ScanDocument').trigger('Change');

if I were to guess, I would say that the capital "C" is the problem. JavaScript is case-sensitive.



来源:https://stackoverflow.com/questions/14174288/jquery-cfml-triggerchange-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!