[Phpmyadmin-devel] jQuery question

Marc Delisle marc at infomarc.info
Sun Sep 12 00:08:35 CEST 2010


Michael Keck a écrit :
> 
> 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

Thanks, this should help me!

-- 
Marc Delisle
http://infomarc.info




More information about the Developers mailing list