Create a custom html attribute

asked 2010-01-08 09:17:26 +0800

nhack gravatar image nhack
63 1


I want to know if there is a way to add a custom attribute to an html tag that is createad by zk.

For example if I use a TextBox and I do something like this:

TextBox tb = new TextBox();

I would like to have in the generate html code something like this:

<textarea myAttr="myValue">

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2010-01-08 15:31:58 +0800

kesavkolla gravatar image kesavkolla
180 3

The custom attributes in ZK are server side attributes. You can only retrieve them on the server. If you need something on the client you will have to either extend the javascript that ZK gives or use some of the non UI related attributes. For example I use zclass attribute to stuck in some information for the client.

You can even try the jQuery option of adding attributes after the components are mounted. Try the following:

zk.afterMount(function() {
jq("$txtBoxId").attr("myAttr", "myValue");

The above will add an attribute to the client after the components are mounted to zk system.


link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools




Asked: 2010-01-08 09:17:26 +0800

Seen: 727 times

Last updated: Jan 08 '10

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More