0

remove sclass from java

asked 2014-09-25 05:49:02 +0800

alexhk gravatar image alexhk
3 2

updated 2014-09-25 12:36:13 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

Dear all,

I can add class through .setSclass("classname"). How can I remove the sclass by just specifying the class name? Thanks!

delete flag offensive retag edit

Comments

I join the question, I got similar problem. Thanks and wait for answer.

andrew90 ( 2014-09-25 09:50:46 +0800 )edit

Your question is not clear what is the your exact requirement please specify in details?

sjoshi ( 2014-09-25 12:37:11 +0800 )edit

terrytornado: thanks for your answer, it is exactly what i want! ^^

alexhk ( 2014-09-26 01:44:05 +0800 )edit

than make a vote and close the thread as answered :-)

terrytornado ( 2014-09-26 10:33:26 +0800 )edit

3 Answers

Sort by ยป oldest newest most voted
1

answered 2014-09-25 12:47:59 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

updated 2014-09-26 17:00:30 +0800

zul with MVVM composer binding:

. . .
<style>.redTextColor { color: red; }</style>

<button id="btnTest" label="test button" onClick="@command('btnTestClick')" />
<label id="labelTest1" sclass="redTextColor" value="text text text text text text"/>

ViewModel:

. . .

@Init
public void initSetup( @ContextParam(ContextType.VIEW) Component view) {
}

@Command
public void btnTestClick(@SelectorParam("#labelTest1") Label labelTest1) {
   if (labelTest1 != null) {
      String _id = labelTest1.getId();
      String _classname = "redTextColor";
      String s = "ox_removeClass('" + _id + "'" + "," + "'" + _classname + "')";

      System.out.println(s);
      Clients.evalJavaScript(s);
}

javascript

    /**
     * Removes a class name from the zk components sclass.
     * 
     * @param id
     *            the zk component id.
     * @param className
     *            The class name to remove.
     */
    function ox_removeClass(id, className) {

        if (id !== null) {
            if (jq('$' + id).hasClass(className)) {
                jq('$' + id).removeClass(className);
            }
        }
    }


/*
 * Adds a class name to zk component sclass.
 * 
 * @param id
 *            the zk component id.
 * @param className
 *            The class name to remove.
 */
function ox_addClass(id, className) {
    if (id !== null) {
        if ( ! jq('$' + id).hasClass(className)) {
            jq('$' + id).addClass(className);
        }
    }
}

best Stephan

link publish delete flag offensive edit
0

answered 2014-09-26 02:10:53 +0800

hawk gravatar image hawk
3225 1 5
http://hawkphoenix.blogsp... ZK Team

if you have only one scalss, you can set empty string to remove it. if you have set multiple sclasses, "myclass1 myclass2", you have to get sclass first, split it with space character, filter out one of sclasses, then set result sclass back.

link publish delete flag offensive edit
0

answered 2014-09-29 13:54:09 +0800

poster gravatar image poster
1
http://www.finansomania.c...

thanks you very helped me

link publish delete flag offensive edit

Comments

In stead of "spamming" with useless answers, just upvote the answer that helped you.

chillworld ( 2014-09-29 15:28:39 +0800 )edit
Your answer
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

Follow
1 follower

RSS

Stats

Asked: 2014-09-25 05:49:02 +0800

Seen: 78 times

Last updated: Sep 29 '14

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