Closed (duplicate)
Project:
Flag
Version:
6.x-1.0-beta2
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
18 Jun 2008 at 12:18 UTC
Updated:
26 Sep 2008 at 14:29 UTC
Jump to comment: Most recent file
We currently have:
function flagClick(element, settings) {
...
$.ajax({
...
success: function (data) {
// Display errors
if (!data.status) {
// Change link back
flipLink(element, settings);
...
});
// Swap out the links.
flipLink(element, settings);
}
But the 'element' that flipLink() uses, under the "Change link back" line, no longer exists: the outer flipLink(), under the "Swap out the links" line, swapped it out of the DOM.
(This bug seems negligible, but the bigger issue here is that we lose the element --and I need to have it, for a future feature.)
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | flag_saveelement.diff | 3.87 KB | mooffie |
Comments
Comment #1
mooffie commentedAssigning to self.
Comment #2
quicksketchI just ran into this bug also when working on making the flag() function work with comments. If Flag returns back
{ status: false }, that second flipLink() causes a JS error. So this would be great to fix to help gracefully fail.Comment #3
mooffie commentedHere's a demonstration patch, but it's only the starting point (so I'm not marking this 'needs review'). Support should yet be added to 'links' that don't contain a link at all (for example, if we theme the link to show a static text: "You bookmarked this post, thanks!").
Comment #4
mooffie commentedBTW, this issue is much more important than it seems.
The purpose here is to make the 'success' handler have access to the element. This gives us, in the near future, the ability, in this handler, to pull the link's texts from the server instead of, or in addition to, storing them in a huge JS structure. This is needed if our links are brought into the page via ajax, so this is need for Views2's ajax feature. This is also needed for two features I'm planning.
Comment #5
mooffie commentedI think we should leave that to a different issue, because else the code will get more complicated and the review process might be lengthy.
So I'm marking this patch 'needs review'.
You may be tempted to think that the old code _does_ handle 'links' that don't contain an <a> tag, because it has:
but this isn't so: this structure just means "if there's no <a> whithin, then it's surely the outer element that's the <a>".
Comment #6
mooffie commentedComment #7
mooffie commentedNote that I don't do $newLink.find('a') because there might be links there that we shouldn't touch, e.g. the themer may put a help link there.
Comment #8
quicksketchAnother option is to simply not keep all that data on the page at load-time. In our AJAX request, return the needed information back to the page. It'll be a bit slower, but personally I don't find the immediate toggling that helpful, and it makes me feel like nothing happened.
Comment #9
mooffie commentedThis issue is superseded by:
#313862: Fix, and enhance, the AJAX support