> $(document).ready( function() {
> $('[EMAIL PROTECTED]').each( function() {
> $(this).blur( function() {
> $.AjaxCFC({
> url: "/namechangedtoprotecttheinnocent.cfc",
> method: "updateAttendee",
> data: {
> fid:this.id,
> field:this.id.split("_")[0],
> id:this.id.split("_")[1],
> value:this.value
> },
> success: function(r){
> $('#'+r).css("backgroundColor","#ddFFdd");
> }
> });
> $(this).css("backgroundColor","#FFdddd");
> });
> });
> });
Well it looks like the variables you need to access are all a part of
the DOM element, right? So you can access that element by the same
'this' variable because both the blur and the once function reassign
'this' to be the DOM element. I am again using my plugin to make the
code simpler, but you don't need to.
Code:
var fn = function(e) {
if (e && e.type == 'blur') $(this).stop();
$.AjaxCFC({
url: "/namechangedtoprotecttheinnocent.cfc",
method: "updateAttendee",
data: {
fid:this.id,
field:this.id.split("_")[0],
id:this.id.split("_")[1],
value:this.value
},
success: function(r){
$('#'+r).css("backgroundColor","#ddFFdd");
}
});
$(this).css("backgroundColor","#FFdddd");
}
$(whatever).blur(fn).keyup(function() {
$(this).once(2000,fn);
}).keydown(function() {
$(this).stop();
});
Let me know if that works.
-blair
Daemach wrote:
> Grrr Nabble is tricky ;) Try this thread:
> http://www.nabble.com/forum/ViewPost.jtp?post=9089663&framed=y
>
>
>
> Blair Mitchelmore-2 wrote:
>> Could I maybe see the code? It's hard to customize something to a
>> situation I nothing about.
>>
>> -blair
>>
>> Daemach wrote:
>>> OK I played around with this for a while with a fresh head. As I
>>> understand
>>> it, the main power of closures is that they retain the environment in
>>> which
>>> they were created. I'm not sure how that applies here, since closures
>>> have
>>> to be defined inside of another function then returned to retain that
>>> environment, but I'm sure it's something I'm overlooking.
>>>
>>> The problem with the code below is that I need to pass other variables in
>>> addition to the event, such as the id and value of the input element
>>> that
>>> this event handler is being registered on - how can I do this with the
>>> below
>>> code?
>>
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/