I thought about it a bit more and you're right, inline code should fire.
So I did a test and I can get the following code to work and set focus after
the ajax call.

here's index.cfm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
 <script src="/jscript/jquery-1.4.2.min.js"></script>
<script>
 $(document).ready(function(){
$.ajax({ url: "/testCode/getCode.cfm", context: document.body, success:
function(data){
 // do nothing;
$('#mydata').html(data);
}});
 });
</script>
</head>
<body>

<DIV ID="mydata" style="background-color:#eaeaea;border:1px solid
#c7c7c7;height:400px;"></div>

</body>
</html>




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Here's getCode.cfm

<cfform name="LoginForm">
 <table id="LoginBox">
<tr height="21">
     <td width="100"><b>Access ID</b></td>
        <td width="100"><cfinput name="AccessID" validate="range"
range="1000,4999" value="" size="8" required="yes" message="A valid Access
ID is required" /></td>
 </tr>
<tr height="21">
     <td><b>Password</b></td>
        <td><cfinput name="Password" type="password" value="" size="8"
required="Yes" message="A password is required" /></td>
 </tr>
    <tr height="21">
<td colspan="2"><span class="fineprint">Remember me on this
computer</span><input type="checkbox" name="Remember" value="Yes"></td>
 </tr>
</table>
<cfinput name="Submit" type="image" value="Submit"
src="../Buttons/MSubmit.png"  />
</cfform>
<script>
document.LoginForm.AccessID.focus();
</script>





On Sun, Sep 26, 2010 at 9:23 AM, Andrew Scott <[email protected]>wrote:

>
> That is actually a good point Michael, and the other thing to note which
> catches a lot of people out, is that the functions should be along the
> lines
> of
>
> myFunction = function() {} as noted by Adobe in their docs.
>
> But having said this, I am almost positive that inline JS outside of a
> function should still load and fire. I am almost 100% positive I have done
> that before.
>
> Regards,
> Andrew Scott
> http://www.andyscott.id.au/
>
>
> > -----Original Message-----
> > From: Michael Grant [mailto:[email protected]]
> > Sent: Sunday, 26 September 2010 11:23 PM
> > To: cf-talk
> > Subject: Re: Trying to set cfform focus in an Ajax window
> >
> >
> > Well you at least have your form and js set up right now.
> >
> > And after going back and re-reading your post I see this is ajax. IIRC
> in-line
> > javascript in ajax content doesn't automatically fire. Most likely this
> is
> a
> > security thing. So that gives you two options (at least).
> >
> > 1. Wrap your JS code at the bottom of the page in a function and execute
> the
> > function when the ajax call completes.
> > 2. Add your focus setting code into a callback function on the ajax call.
> >
> > Either one will work, it's just a matter of whether or not your caller
> will be
> > aware of the form and fieldname you want to focus on.
> >
> > HTH.
> >
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:337560
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to