I have the following problem: I've bound XBL "rule" via css, but when
I change the content of DOM element (whom XBL was bound) nothing is
changed on screen.... Take a look at the simplified example:
html file:
<html>
<style>
.ellipsis {
overflow: hidden;
text-overflow: ellipsis;
-moz-binding: url(ellipsis.xml#ellipsis);
white-space: nowrap;
width: 40px;
height: 20px;
border: 1px solid red;
}
</style>
<script>
function change() {
document.getElementById("long-text").innerHTML = "short";
}
</script>
<body>
<div id="long-text" class="ellipsis">longgggggggggggggg</div>
<input type="button" onclick="change();" value="change text in div"></
button>
</body>
</html>
XBL:
<?xml version="1.0"?>
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/
there.is.only.xul"
>
<binding id="ellipsis">
<content>
<xul:description crop="end"
xbl:inherits="value=xbl:text"><children/></xul:description>
</content>
</binding>
</bindings>
open html file and press a button "change text in div". At the
beginning you see "lon...", after pressing I expect to see "short",
but I don't see any changes. fun that innerHTML is really changed, so
it works but looks like XBL is not fired or... how to deal with that,
what I've missed???
thank you!
Nothing that I see. I don't see any provisions in the xbl code for
updating things when xbl:text is used on the RHS of an xbl:inherits and
the text is changed.
-Boris
As I understand, the thing I wanna implement is impossible?
Another way, if I change text, can I fire any event, or set anything
via JavaScript to let XBL change text too?
What I need is just to emulate "text-overflow" css property in
FireFox. At the beginning the approach using binding looked great, but
now I see this pitfall with dynamic changes...
Maxym
<?xml version="1.0"?>
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xul="http://
www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="ellipsis">
<content>
<xul:label crop="end" style="width: 100%;"><children /></
xul:label>
</content>
<implementation>
<method name="setTextContentToValue">
<body><![CDATA[
var eDescription = document. getAnonymousNodes(this)[0];
if (eDescription) eDescription. value = this.textContent;
// ]]></body>
</method>
<constructor>setTextContentToValue();</constructor>
</implementation>
<handlers id="none">
<handler event="DOMSubtreeModified">setTextContentToValue();</
handler>
</handlers>
</binding>
</bindings>
the source of solution (in Russian, but anyway xbl/html code is
enought to experiment):
http://www.leechy.ru/howto/text-overflow/
regards,
Maxym
On 5 Січ, 17:00, Boris Zbarsky <bzbar...@mit.edu> wrote:
Using xbl:inherits and without fixing the underlying XBL bug, yes.
-Boris
....
<xul:label anonid="label" ...
....
and in related css I defined:
[anonid="label"] {
-moz-user-select: text;
}
but it does not work. Is the idea of processed text selecting utopia?
thank you,
Maxym