Footniko
Footniko

Reputation: 2752

Mootools inject after not working

Mootools code:

window.addEvent('domready', function() {
    var homeLink = $$('a.pathway');
    new Element('a', {'href': '/ru/produktsiya', 'html': 'Click me!'}).inject(homeLink, 'after');

});

Why didn't work?

Upvotes: 0

Views: 1123

Answers (1)

rgthree
rgthree

Reputation: 7273

$$ returns a collection of elements, which you cannot inject a single element after, of course.

window.addEvent('domready', function() {
  var homeLink = $$('a.pathway');
  new Element('a[href="/ru/produktsiya"][text="Click me!"]'}).inject(homeLink[0], 'after');
});

You can also use CSS selector logic to more easily create elements, as I've done above:

Upvotes: 2

Related Questions