If you're bypassing bindings, you can dispense with your initial binding:
<cfdiv id="myDiv" bind="url:bind_get_art.cfm?artistID={artistID}"></cfdiv>
bypassing
<cfdiv id="myDiv" bind="url:someinitialpage.cfm"></cfdiv>

Now if you're just displaying a single value, rather than a chunk of HTML,
you can make things a bit lighter using a CFC and AJAX proxy.

<cfajaxproxy cfc="path.to.art.cfc" jsclassname="jsArt">

<script>
var objArt= new jsArt();
function loadResults(artistId) {
    document.getElementById('resultsPanel').innerHTML=objArt.getArt(artistId);

}
</script>

<a href="nonjspage.cfm?artistId=1" onClick="loadResults(1);return
false();">artist 1</a>
<a href="nonjspage.cfm?artistId=2" onClick="loadResults(2);return
false();">artist
2</a>
<a href="nonjspage.cfm?artistId=3" onClick="loadResults(3);return
false();">artist
3</a>
Name of art: <span id="resultsPanel"></span>

Code wise, it's a bit more, but I like returning clean data structures, not
presentation, from my objects. That way you total flexibility with what you
do with what is returned, and allows you to reuse CFC's on varying,
disparate pages.

Billy Cravens


On Fri, Nov 20, 2009 at 9:40 AM, Ken Auenson, II <[email protected]>wrote:

> Mark,
> I haven't done much AJAX using the built in ColdFusion tags, so my solution
> would use jQuery and be vastly different so I won't bother posting.
> But I did find this article by Ray Camden where he shows how to update a
> cfdiv using a JavaScript call:
>
> http://www.coldfusionjedi.com/index.cfm/2007/7/19/Building-an-auto-refresh-div-with-ColdFusion-8
>
>
> <http://www.coldfusionjedi.com/index.cfm/2007/7/19/Building-an-auto-refresh-div-with-ColdFusion-8>Based
> on that, I think you could setup a click handler on your links.  A simple
> example would be:
>
> <cfdiv id="myDiv" bind="url:bind_get_art.cfm?artistID={artistID}"></cfdiv>
> <a href="get_art_noJS.cfm?artistID=1"
> onClick="ColdFusion.navigate('bind_get_art.cfm?artistID=1', 'myDiv');return
> false;" >First Art</a>
> <a href="get_art_noJS.cfm?artistID=2"
> onClick="ColdFusion.navigate('bind_get_art.cfm?artistID=2', 'myDiv');return
> false;" >Second Art</a>
>
>
> If that isn't clear, I assumed you have a get_art_noJS page that the user
> will be directed to if they do not have JS enabled, and because I have "return
> false;" in the click event, if a user has JS enabled, that link will not
> be used and instead the ColdFusion.navigate code will be called.  This is a
> crude way to gracefully degrade the functionality of the page for non-JS
> users.
>
> This code isn't tested and may be completely incorrect [and I am sure this
> isn't "best practice"], so buyer beware :)
>
> --Ken
>
>
> On Fri, Nov 20, 2009 at 9:17 AM, Mark Davis <[email protected]>wrote:
>
>>  I am looking at replacing some pages in am old app with some AJAX stuff
>> but am having trouble finding exactly what I am looking for.
>>
>> I want to bind a cfdiv to the results of a cfc such as this...
>>
>>
>> <cfdiv bind="url:bind_get_art.cfm?artistID={artistID}"></cfdiv>
>>
>> but every example I find is using a cfform element to determine the variable 
>> in the bind.
>>
>> How can I accomplish this from a link on the page instead of a cfform?  So 
>> user clicks a link and the div gets bound to the results of the url (or even 
>> better, a cfc function call)
>>
>> Thanks.
>>
>> Mark
>>
>>  --
>> You received this message because you are subscribed to the "Houston
>> ColdFusion Users' Group" discussion list.
>> To unsubscribe, send email to [email protected]
>> For more options, visit http://groups.google.com/group/houcfug?hl=en
>
>
>  --
> You received this message because you are subscribed to the "Houston
> ColdFusion Users' Group" discussion list.
> To unsubscribe, send email to [email protected]
> For more options, visit http://groups.google.com/group/houcfug?hl=en
>

-- 
You received this message because you are subscribed to the "Houston ColdFusion 
Users' Group" discussion list.
To unsubscribe, send email to [email protected]
For more options, visit http://groups.google.com/group/houcfug?hl=en

Reply via email to