[jQuery] AjaxCFC (paging Rey Bango...)

[jQuery] AjaxCFC (paging Rey Bango...)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.5730.11" name=GENERATOR><!--[if !mso]>
<STYLE>v\:* {
BEHAVIOR: url(#default#VML)
}
o\:* {
BEHAVIOR: url(#default#VML)
}
w\:* {
BEHAVIOR: url(#default#VML)
}
.shape {
BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]-->
<STYLE>@font-face {
font-family: Tahoma;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in 1.25in; }
P.MsoNormal {
FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; COLOR: black; FONT-FAMILY: "Times New Roman"
}
LI.MsoNormal {
FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; COLOR: black; FONT-FAMILY: "Times New Roman"
}
DIV.MsoNormal {
FONT-SIZE: 12pt; MARGIN: 0in 0in 0pt; COLOR: black; FONT-FAMILY: "Times New Roman"
}
A:link {
COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlink {
COLOR: blue; TEXT-DECORATION: underline
}
A:visited {
COLOR: blue; TEXT-DECORATION: underline
}
SPAN.MsoHyperlinkFollowed {
COLOR: blue; TEXT-DECORATION: underline
}
PRE {
FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; COLOR: black; FONT-FAMILY: "Courier New"
}
SPAN.EmailStyle18 {
COLOR: navy; FONT-FAMILY: Arial; mso-style-type: personal-reply
}
DIV.Section1 {
page: Section1
}
</STYLE>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-US vLink=blue link=blue bgColor=white>
<DIV dir=ltr align=left><SPAN class=590510722-06022007><FONT face=Arial
color=#0000ff size=2>Most of the time, I'm using the CFC to do all of the
formatting, then I return a simple string containing all of the HTML that needs
to be applied to the page. For example. take a look at <A
href="http://www.co-opcookbook.com">www.co-opcookbook.com</A>. That's where I
pulled that sample code from.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=590510722-06022007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=590510722-06022007><FONT face=Arial
color=#0000ff size=2>When you perform a search, it runs the CFC using the
provided keyword. The CFC queries the database, loops over the results, adding
in the appropriate HTML, then returns that long string of  text to the
calling JS function.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=590510722-06022007><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=590510722-06022007><FONT face=Arial
color=#0000ff size=2>That might not be the most efficient way of doing things
(if it's not PLEASE someone speak up, I want to get better), but it's the way
that makes sense to me.</FONT></SPAN></DIV><BR>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
<HR tabIndex=-1>
<FONT face=Tahoma size=2><B>From:</B> discuss-bounces@jquery.com
[mailto:discuss-bounces@jquery.com] <B>On Behalf Of </B>Paul<BR><B>Sent:</B>
Tuesday, February 06, 2007 4:05 PM<BR><B>To:</B> 'jQuery
Discussion.'<BR><B>Subject:</B> Re: [jQuery] AjaxCFC (paging Rey
Bango...)<BR></FONT><BR></DIV>
<DIV></DIV>
<DIV class=Section1>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Andy, this is also good
to know.  I guess I’ll figure this out eventually, but what doesn’t yet
make sense is how to handle complex objects (queries, structs) being returned
from the CFC.  Do you just handle the formatting in your CFC so you can
pass back (or simply output, I guess) a string and use $(“#element”).html() to
replace the content, or do you handle formatting on the client side?  (By
“you” I mean Andy specifically but the rest of you generally as
well…)<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">I’m learning a
lot…<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial">Paul<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=navy size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: navy; FONT-FAMILY: Arial"><o:p> </o:p></SPAN></FONT></P>
<DIV>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT
face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt; COLOR: windowtext">
<HR tabIndex=-1 align=center width="100%" SIZE=3>
</SPAN></FONT></DIV>
<P class=MsoNormal><B><FONT face=Tahoma color=black size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT
face=Tahoma color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: windowtext; FONT-FAMILY: Tahoma">
discuss-bounces@jquery.com [mailto:discuss-bounces@jquery.com] <B><SPAN
style="FONT-WEIGHT: bold">On Behalf Of </SPAN></B>Andy Matthews<BR><B><SPAN
style="FONT-WEIGHT: bold">Sent:</SPAN></B> Tuesday, February 06, 2007 2:07
PM<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> 'jQuery
Discussion.'<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re:
[jQuery] AjaxCFC (paging Rey Bango...)</SPAN></FONT><FONT color=black><SPAN
style="COLOR: windowtext"><o:p></o:p></SPAN></FONT></P></DIV>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">Just so you know, you
CAN use jQuery to hit the CFC directly. Here's a sample of code I'm
using:</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">js
code:</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">function addRecipe(id)
{<BR> $.get("includes/q.cfc?method=addRecipe&id=" +
id,function(result){<BR>  eval( 'var ' + result
);<BR>  $('#shoppingList').html(r.content);<BR> });<BR>};</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial">CFC:</SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face=Arial color=blue size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial"><cffunction
name="addRecipe" access="remote" returntype="void" hint="Adds a recipe to your
shopping list"><BR> <!--- set parameters for arguments
---><BR> <cfargument name="id" required="Yes"
type="numeric"><BR> <cfset myStruct =
structNew()><BR> <cfif NOT
ListFind(SESSION.grocerylist,id)><BR>  <cfset
SESSION.grocerylist =
ListAppend(SESSION.grocerylist,id)><BR> </cfif><BR> <cfset
myStruct["content"] =
Replace(getShoppingList(),"#chr(13)#","","ALL")><BR> <cfwddx
action="CFML2JS" input="#myStruct#"
toplevelvariable="r"><BR></cffunction></SPAN></FONT><o:p></o:p></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"> <o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" color=black size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P><PRE><FONT face="Courier New" color=black size=2><SPAN style="FONT-SIZE: 10pt"><o:p> </o:p></SPAN></FONT></PRE></DIV></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/