[Phpmyadmin-devel] jQuery question
Michael Keck
sfnet at michaelkeck.de
Sat Sep 11 20:01:21 CEST 2010
Hi Marc,
On Sat, 11 Sep 2010 08:37:59 -0400, Marc Delisle <marc at infomarc.info>
wrote:
> Hi,
> this works on a input element:
>
> var this_name = $(this).attr('name');
>
> so I'm trying to do the same to extract the code inside the onchange
> "attribute":
>
> var this_onchange = $(this).attr('onchange');
this won't work.
> but Firebug tells me that this_onchange is an event;
yepp that's right
> it does not contain the code. I need to do subsequent string matching and
> replacement in this code.
Please use a function call for this, and replace silly the params:
$(this).unbind('change');
$(this).bind('change', function(e) {
// your function call
// something like:
// pma_js_function_to_call(param1, param2, para,X)
});
Other solution is to work with a string, make your string replacement and
after this use the eval-function. Sample:
$(this).unbind('change');
$(this).bind('change', function(e) {
eval(your_replaced_string);
});
But eval is devil:
The eval function (and its relatives, Function, setTimeout, and
setInterval) provide access to the JavaScript compiler. This is sometimes
necessary, but in most cases it indicates the presence of extremely bad
coding. The eval function is the most misused feature of JavaScript.
Regards
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20100911/fed8e74a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 583 bytes
Desc: OpenPGP digital signature
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20100911/fed8e74a/attachment.sig>
More information about the Developers
mailing list