It sounds like you're talking about jQuery manipulating jQuery code?

Onclicks created by jQuery are assigned after the DOM is loaded, and
wouldn't be found in the rendered HTML code. If the action attribute of the
form is abc.xyz in HTML, and then you run your code to make it
abc.xyz?something=else, you'd have to reassign your click handlers.

What I'd do is to create a function which encapsulates the form click
handler assignments, and call that after your below jQuery code like so:

$(document).ready(function() {
  var regexp = /action=([a-zA-Z]+\.[a-zA-Z]+)/;
  var value = $("form").attr('action');
  var replaced = value.replace(regexp,'action=$1&cte=thompson');
  $("form").attr('action',replaced);
  assignClickHandlers();
});





-----Original Message-----
From: Will Tomlinson [mailto:w...@wtomlinson.com] 
Sent: Friday, February 19, 2010 2:14 PM
To: cf-talk
Subject: Re: jquery find/replace on an entire body DOM


>Anything you could do to make jQuery have to do less work will be 
>beneficial.
>

Andy,

This works great for form actions. I've played around with doing the exact
same thing for any inputs with onclick attributes. But JQ doesn't seem to
select up the value of the onclick. Do you have any ideas? 

Here's the form one that works. 

$(document).ready(function() {
  var regexp = /action=([a-zA-Z]+\.[a-zA-Z]+)/;
  var value = $("form").attr('action');
  var replaced = value.replace(regexp,'action=$1&cte=thompson');
  $("form").attr('action',replaced);
});

Thanks!

Will 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:330953
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to