Edit part of page loaded by ajax
|
|
Hello again! Another problem:
<ul id="friendList" class="friendList"> <li id="friend4244" class="fakeLink3"> </ul> <ul id="friendList" class="friendList" /> The first ul will be filled with a lot of li elements which are requested by an XHR. They're all alike, have the same className and similar IDs (only the number will change).
I want to make my Monkey do that for me without having to click 1000 times ;-) The code on the page which is responsible for that gimmick is the following:
function addInvite(id) {
eleInv = $('friend'+id);
if (eleInv) {
JGroupsHelper.addGroupInvite([id]);
o = loadedFriends.get(id);
selectedFriends.set(id, o);
loadedFriends.unset(id);
var container = $('invites');
if (container) {
var li = createInviteNode(id, o);
container.appendChild(li);
}
eleInv.remove();
}
}
Not exactly sure what JGroupsHelper does or is. It might be another AJAX fancy for the server to send the friend ID. /edit: It is. The easiest way to do it will probably be just to execute addInvite(id).
Just executing unsafeWindow.addInvite("myid"); did not work. Any other way to do this? :) Thanks a lot, people. |
|
|
<ul id="friendList" class="friendList"> <li id="friend4244" class="fakeLink3"> </ul> <ul id="friendList" class="friendList" /> You can't have two elements with the same ID. Once the ajax request is complete, something like this should work:
var listArray = document.getElementById('friendList').getElementsByTagName('li');
var newUL = document.getElementById('friendList2');
for(var i = 0; i<listArray.length; i++){
newUL.appedChild(listArray[i]);
}
|
|
|
My bad, the second ul has the id invites.
/edit: Nope: |
|
|
Nope: alert(document.getElementById("friendList").getElementsByTagName("li") Then there must only be one li descendant element. |
|
|
Sweeeeet, it worked. ( |
|
|
Sweeeeet, it worked. (setTimeout()) Cool, glad i could help. :) |
|
|
Ah, nevermind:
But unfortunately, one needs to actually click the li items in the first ul, so the request is started.
Is there a way to fake an event? In this case, click all the lis?
|
|
|
Can you post a link to the page? |
|
|
Here's an example mouse event creation on mozdev Between that example and what Mikado showed us I think you can accomplish whatever it is youre exactly doing |
|
|
Awesome, I finally figured it out. This will make things much much easier for everyone. Thank you so much. |
|
|
no0n wrote: OTIt's MDC (Mozilla Development Center) — previously known as devmo (developer.mozilla.org) — don't call it mozdev (www.mozdev.org). |
