I have code of this form:
$('.inline-label').entwine({
onmatch: function() {
...
console.log('.inline-label onmatch');
this._super();
},
onunmatch: function() {
...
console.log('.inline-label onunmatch');
this._super();
});
If I add the following entwine declaration:
$('input.ajax-validate').entwine({
onmatch: function() {
this._super();
},
onunmatch: function() {
this._super();
});
Then the onmatch does not get called for the .inline-label entwine
declaration. Is this a bug or am I not doing something correctly?
Thanks!
Can you send me a DOM snippet? That way I can write a test for the
exact structure that's failing.
The known bug is that, unlike with other events & functions, declaring
two blocks with _the same selector_ won't set up inheritance, but will
just overwrite the definition.
$('.foo').entwine({
bar: function(){ console.log('bar:1'); }
onmatch: function(){ console.log('onmatch:1'); }
})
$('.foo').entwine({
bar: function(){ console.log('bar:2'); this._super(); }
onmatch: function(){ console.log('onmatch:2'); this._super(); }
})
Given that, onmatch will only log 'onmatch:2', whereas calling $
(element).bar() will log 'bar:2' then 'bar:1'. I've got an uncommitted
fix for this - I must remember to commit it.
Hamish
The output of the following test is:
bar
foo method
bar method
The foo and bar methods are correctly attached to the element.
However, only the onmatch handler for bar is called.
<html>
<head>
<title>Entwine Bug</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery.entwine-dist.js"></
script>
<script type="text/javascript">
(function($) {
$('.foo').entwine({
onmatch: function() {
console.log('foo');
},
onunmatch: function() {
},
foo: function() {
console.log('foo method');
}
});
$('.bar').entwine({
onmatch: function() {
console.log('bar');
},
onunmatch: function() {
},
bar: function() {
console.log('bar method');
}
});
$(document).ready(function() {
$('#element').foo();
$('#element').bar();
});
})(jQuery);
</script>
</head>
<body>
<div id="element" style="width: 100px; height: 100px; border: 1px
solid;" class="foo bar"></div>
</body>
</html>
Hey, Hamish, are you using entwine in any "real-world" apps? Haven't
seen much activity here lately, and it's nice to know I'm not the only
one using this :).
Josh
Sent from my iPhone
I'm baffled as to why entwine hasn't gotten much traction!
Ah, but position is the last element in css specificity (it's included
in the css spec in the specificity calculation section). I need to
make the documentation clearer about this I think.
> Hey, Hamish, are you using entwine in any "real-world" apps? Haven't
> seen much activity here lately, and it's nice to know I'm not the only
> one using this :).
Yeah, it's under pretty much constant use, including in a couple of
pretty big web apps. The reason I haven't done anything on it lately
is that it does everything I need. I don't really believe in adding
API just for the sake of it if there isn't any use case, and nobody's
really come back with feature requests.
That being said, I'll be putting together another release fairly soon.
It'll include a couple of bug fixes (this one and an issue with
onchange emulation in IE), and a couple of features that I'd almost
certainly use once they're more stable.
If you guys are feeling any pain points in using it, let me know.
Hamish
This is an area I could definitely stand to improve on - tracking down
the call chain on a complex site. I've been meaning to see how hard a
firefox extension would be that could show you what functions are
bound to what elements.
> I'm baffled as to why entwine hasn't gotten much traction!
Me too. I think it's partly lack of exposure - other than the one
Ajaxian post, there hasn't been that much visible news about it - and
partly a lack of instantly obvious payback. One of the reasons for a
new release is so we can have another round of announcements, try to
improve awareness. I'm also probably going to try and do an entwine
powered space invaders clone as an example / intro to entwine thingy.
A pretty logo & homepage would probably help too :).
Hamish
Ah, but position is the last element in css specificity (it's includedin the css spec in the specificity calculation section). I need to
make the documentation clearer about this I think.
If you guys are feeling any pain points in using it, let me know.