The site I'm working on is using jquery waypoints version 3.1.1. I can destroy a waypoint from within it's handler like so:
>>> synonyms = wordnet.synsets('change')
>>> set(chain.from_iterable([word.lemma_names() for word in synonyms]))
set([u'interchange', u'convert', u'variety', u'vary', u'exchange', u'modify', u'alteration', u'switch', u'commute', u'shift', u'modification', u'deepen', u'transfer', u'alter', u'change'])
but not like this:
var foo = $('#myElem').waypoint({
handler: function() {
// do something
this.destroy();
},
offset: 'bottom-in-view'
});
I get the error:
foo.destroy();
I also can't destroy it from a context basis:
foo.destroy is not a function
I get the error:
var ctx = Waypoint.Context.findByElement($('#myElem'));
ctx.destroy();
The only way I can destroy a waypoint is from within the handler or using destroyAll:
Cannot read property 'destroy' of undefined
but I can't use destroyAll as there are other wyapoints on the page that I don't want destroyed. Ideally I can do it on a per waypoint basis like so:
Waypoint.destroyAll();
or at the very least on a context basis. What's the issue here, I'm following the docs but not getting the expected results. Perhaps because I'm using an older version?
答案 0 :(得分:1)
foo is an array, so you would need to write:
>>> repr(mention.id)
'698147667990441984'
>>> repr(698147667990441984)
'698147667990441984'
>>> mention.id is 698147667990441984
False
>>>
Also consider this from imakewebthings.com/waypoints:
There is one major difference between using the
foo[0].destroy();
method with versions 2.0 and 3.0. In 2.0, the same jQuery object was returned for chaining purposes, as is common among core jQuery methods. In 3.0, an array of$.fn.waypoint
instances is returned.