Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-04-19 03:06:24

Siguo
Member
From: Beijing, China
Registered: 2008-05-22
Posts: 44

make a more power finput

this is the finput function in txplib_forms.php at present:

function fInput($type, $name…,$onClick=’‘,…)
{
….
$o .= ($onClick) ? ‘ onclick=”’.$onClick.’”’ : ‘’;
….
return $o;
}

the problem is I only can set onclick handler for the finput, sometimes I prefer to onblur, onfocus…etc.

so can we make this function like this:

function fInput($type, $name…,$onevent=’‘,…)
{
….
$o .= ($onevent) ? ‘ $onevent : ‘’;
….
return $o;
}

thus, we can set the onclick, onblur, onfocus…like this:

$html1 = finput(…..onevent = ‘ onclick=“clickhandler(); “’);
$html2 = finput(…..onevent = ‘ onblur=“blurhandler(); “’);
……

Offline

#2 2010-04-19 03:20:36

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: make a more power finput

Nice idea Siguo, but I will have to give this -1. Actually if there weren’t older releases to worry about, I would vote opposite and say that we remove all inline JavaScript events (and inline styles) from all html shortcut functions. Maybe the removal can take place in the next major release.

If you are using that remember to add the additional parameter to last in the list. If you set it to the middle, it might break some things.

Anyways, if you need JavaScript events, you can use them from JavaScript. It’s, in my opinion, more preferred than inline JS and makes TXP’s code cleaner. And so is centralized CSS than inline styles.

Last edited by Gocom (2010-04-19 03:27:23)

Offline

#3 2010-04-19 05:00:28

Siguo
Member
From: Beijing, China
Registered: 2008-05-22
Posts: 44

Re: make a more power finput

I agree with you, Gocom. I will handle event attach from Javascript. thanks.

Offline

Board footer

Powered by FluxBB