Need to Make Title attribute of Div Container Dynamic
posted 2 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I am attempting to make the title of a div container dynamic based on specific value.
Using the following script when I hover over the container if the value == 2 I get "First" otherwise I get "class".
Using the following script when I hover over the container if the value == 2 I get "First" otherwise I get "class".
posted 2 years ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
If you look at the generated HTML you should see the problem.
Spoiler:
No quotes around the attribute value so only the first word is parsed as part of the value.
Spoiler:
No quotes around the attribute value so only the first word is parsed as part of the value.
posted 2 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I had to look at this pretty carefully to make sense of that answer.
More accurately, the entire title attribute value needs to be quoted, including the EL code. Use single-quotes to delimit the string result.
This is one reason why I recommend not doing anything complicated in EL on a web page. A much safer/cleaner way would have been to eliminate the conditional EL and literal string and do something like this:
Where the property value for divTitle in backing bean "itemStatusV80obj" would be set to the desired title (or an empty string). The name "itemStatusV80obj", incidentally, is all sorts of ugly, since "obj" is basically redundant and a version number is questionable. Usually "itemStatus" would be enough.
Note that if you want to, you can use an alternate backing bean to hold the "divTitle" property if it would be inappropriate to put it in the itemStatus object.
More accurately, the entire title attribute value needs to be quoted, including the EL code. Use single-quotes to delimit the string result.
This is one reason why I recommend not doing anything complicated in EL on a web page. A much safer/cleaner way would have been to eliminate the conditional EL and literal string and do something like this:
Where the property value for divTitle in backing bean "itemStatusV80obj" would be set to the desired title (or an empty string). The name "itemStatusV80obj", incidentally, is all sorts of ugly, since "obj" is basically redundant and a version number is questionable. Usually "itemStatus" would be enough.
Note that if you want to, you can use an alternate backing bean to hold the "divTitle" property if it would be inappropriate to put it in the itemStatus object.
Experience keeps a dear School, but Fools will learn in no other.
---
Benjamin Franklin - Postal official and Weather observer
| Beauty is in the eye of the tiny ad. The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |













