-
FEATURED COMPONENTS
First time here? Check out the FAQ!
請問我目前Textbox例如有設定rows="4" cols="35" 且css有設定英文自動斷行,但因為css的自動斷行並沒有補換行符號。 我的需求是他如果設定rows="4"就真的只能輸入4行。若超過就要拋警訊。 但若Css沒有補換行符號時,我有辦法抓到目前該Textbox內有幾Row的資料嗎?? 麻煩各位了...
據我所知 ZK 沒有這樣的功能。 我想其他 Framework 也沒這樣的功能,這應該是跟瀏覽器相關,HTML 規範相關的問題。 就算想要用 35 個字符去做一行也是不準的。 妳可以簡單做一個 html 的 textarea 看看 cols = 35 ,並不是每一行就是 35 個字的意思。
參考下面連結 http://www.w3schools.com/tags/atttextareacols.asp
對於 col 屬性的定義 Specifies the width of the text area (in average character width).
average character width 到底是多少呢? 這跟瀏覽器怎麼訂有關係,而且當妳縮放瀏覽器時又會不一樣。
這是個很複雜的問題,以上。
Please refer to sample below:
<zk xmlns:w="client">
<textbox rows="4" cols="35">
<attribute w:name="bind_"><![CDATA[
function (a, b, c) {
this.$bind_(a, b, c);
var inp = this.getInputNode(),
$inp = jq(inp),
wgt = this;
$inp.bind('input', function () {
// has scrollbar
if ((inp.scrollHeight - inp.offsetHeight) > 10) {
$inp.val(''); // clear scrollbar
$inp.val(wgt._latestAllowedValue);
} else {
wgt._latestAllowedValue = $inp.val();
}
});
}
]]></attribute>
</textbox>
</zk>
Asked: 2013-08-28 04:48:50 +0800
Seen: 35 times
Last updated: Sep 09 '13