Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / ColdFusion / Advanced Techniques / August 2008



Tip: Looking for answers? Try searching our database.

Binding to a javascript function is not working

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tinaja - 25 Oct 2007 20:27 GMT
I am trying to use the following code to bind to a javascript function and it's
not working.  I finally had to use jQuery to bind the event handler, but I
would like to see the CF generated stuff work.    Am I missing something here?

This jquery code is the workaround:

    $('.match').change(function(){
        updateSA(this);
    })

<cfinput name="bMatch_#getSA.seminarattendee_id#" class="match"
type="checkbox" checked="#getSA.bMatched#" bind="javascript:updateSA(this)">

The javascript looks like this:

updateSA = function(ele) {
    var o = {};
    var p = new reconcile();
   
    var id = ele.id.split("_")[1];
    var midEle = $('#ministryID_' + id)[0];
    var mcidEle = $('#ministryContactID_' + id)[0];
   
    o.mid = midEle.options[midEle.selectedIndex].value;
    o.mcid = mcidEle.options[mcidEle.selectedIndex].value;
    o.bMatch = 0;
    o.id = id;
   
    if (ele.checked){o.bMatch = 1}
   
    p.setAsyncMode();
    p.setCallbackHandler(ajaxResponse);
    p.updateSA(o);
}

ajaxResponse = function(r) {
    console.log(r);
}
Dan Bracuk - 25 Oct 2007 20:30 GMT
What are you trying to bind to js?  I was always under the impression that
binding was a flash form thing, and that flash forms were swfs, and that swfs
and js don't play with each at all.

But I could be wrong.
Tinaja - 25 Oct 2007 22:19 GMT
Binding is not restricted to flash forms.  I can bind directly to a cfc without
problems, but in this case I need to send more info to the cfc than a single
field would provide.  You're supposed to be able to bind to a javascript
function using the syntax above, but it's not working properly.

More details here:  
http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=ajaxdata_03.ht
ml#1128486
MMFranklin - 28 Aug 2008 21:23 GMT
I believe you may need to use <cfajaxproxy> tag to make this work.

So for instance

<cfajaxproxy cfc="SomeCFC" jsclassname="SomeJS">

then in JS

var x = new SomeJS()
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.