This topic was marked solved by Arantor, on February 10th, 2013, 06:35 PM

emanuele

  • Posts: 125
Remove drafts
« on January 7th, 2013, 05:36 PM »
Searched and not found, so reporting it.

Deleting a single draft doesn't seem to work.

Reproduce:
* write a post/PM
* save ad draft
* go to the draft page in your profile
* click "remove draft"
* confirm with "ok"
=> nothing happens (tested with Opera, so it may even be the browser :angel: )

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Remove drafts
« Reply #1, on January 7th, 2013, 05:48 PM »
Damn, I thought I'd fixed that, thanks for the report.
Re: Remove drafts
« Reply #2, on January 7th, 2013, 06:39 PM »
OK this one is officially weird. The delete link has an event attached to it which calls up ask() (our replacement of confirm()) but when it returns true, it's not calling the default behaviour on the link so nothing happens.
When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest. | Game Memorial

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Remove drafts
« Reply #3, on January 7th, 2013, 06:58 PM »
Hmm is that a bug in ask() or something? Not on my pc right now...

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Remove drafts
« Reply #4, on January 7th, 2013, 07:00 PM »
I don't know. All I know is that it's a regular link with an event attached to return ask('string') in it, the ask() fires, the return seems to be true but the link never fires after.

Should be reproducible on mobile too.

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Remove drafts
« Reply #5, on January 7th, 2013, 11:30 PM »
I have no idea why this isn't working. I traced line by line, including inside jQuery itself, and nothing came up. It just doesn't trigger... Tested with Opera, though, but IIRC it's the same in Chrome.

I'm thinking... Can anyone find the same bug on another <a> tag with an onclick? Maybe the code is fundamentally flawed for anchors and only works on buttons, in which case I'm very, very screwed...
Gotta go for tonight. :(

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Remove drafts
« Reply #6, on January 7th, 2013, 11:38 PM »
After trawling the source, I can only find one other place where we use a 'return ask' as the event on a text link, and that fails too. There are plenty of return reqWin() events, but that's cool because we want to override those.

There is an instance of a window.open but I'm sure that'll get replaced eventually anyway (it's in the moderation centre)

I'll note there are places there probably *should* be an extra such event (e.g. marking everything read) anyway.

Makes me wonder whether instead we should just be using buttons for anything like that though.

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Remove drafts
« Reply #7, on January 7th, 2013, 11:42 PM »
That's a possible alternative... Realistic one, if I can't find the source of the issue.
I'll look into it further tomorrow. Probably by doing some code simplification, like always returning 'true' for ask() and seeing if it works, etc... (You can do it too if you like, it's probably morning for you over there in far away UK :P)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Remove drafts
« Reply #8, on January 7th, 2013, 11:43 PM »
I'm just replacing the mail queue one now, I realise it doesn't solve the problem but it's been bugging me for ages that it's inconsistent visually ;)

Also, what do you mean 'far away UK'? It's an hour behind you :P

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Remove drafts
« Reply #9, on January 8th, 2013, 09:11 AM »
It just makes me smile that you seem to be sleeping in the morning rather than in the night ;)
Posted: January 8th, 2013, 08:48 AM

$('.remove_button').click() doesn't work with _modalDone set to true...
$('.remove_button').unbind('click').click() doesn't work either, but then doing a second manual click on the link works.

So far, all I could find to 'make it work', is do a silly location = e.target.href... Not exactly 'good looking', and it will definitely add a lot of code to reqWin(), even to cancel out the 20 bytes I just saved by rewriting stuff yesterday...

Maybe it's a jQuery bug. I'll try with v1.9.
Re: Remove drafts
« Reply #10, on January 8th, 2013, 10:22 AM »
Pardon my French, but that's one of the sickest sons of a bitch I've ever seen in a jQuery feature.

http://bugs.jquery.com/ticket/12652

Apparently, they *DO* have that bug, and they won't fix it because they don't think it's a jQuery bug (I beg to differ!)

To be more specific: DOMElement.click() only worked on INPUT tags until HTML5 told implementors to support it everywhere. jQuery, for some reason, actually checks, when triggering a $(elem).click() event, whether 'elem' is an anchor. And if it is... Be prepared... It just DROPS the entire process. I should have been more careful when tracing through the code... In jQuery 1.5.2, the test is made at line 2487, with the 'isClick' variable. It just drops it. No warning whatsoever. Unbelievable! And the bug is still in jQuery 1.9 beta, line 2989.

So, I've implemented the shortest possible 'valid' workaround for it. And this now uses 22 gzipped bytes. i.e., the exact amount of data I saved yesterday. (Original code in script.js only has the last line of this snippet, if you want to locate it and test it.)

Code: [Select]
if (e.type == 'click' && e.target.href)
location = e.target.href;
else
$(e.target).trigger(e.type);

And a final 'fuck you' to everyone involved in this bug for wasting emanuele's, Pete's and my valuable time.

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Remove drafts
« Reply #11, on January 8th, 2013, 04:16 PM »
That's just nasty.

Dragooon

  • I can code! Really!
  • polygon.com has to be one of the best sites I've seen recently.
  • Posts: 1,841
Re: Remove drafts
« Reply #12, on January 8th, 2013, 05:12 PM »
Funny thing is, doing $(a).click() on jquery mobile works as expected (because of the way it handles clicking)
The way it's meant to be

Nao

  • Dadman with a boy
  • Posts: 16,080
Re: Remove drafts
« Reply #13, on January 8th, 2013, 06:21 PM »
Yeah, it's nasty... Especially for someone like me who enjoys saving bytes one by one.

Okay, so I saved 4 bytes off these by ensuring that Wedge doesn't call <a onsomethingelsethanclick="return ask();">... Which it didn't, in the first place, so good. Now I don't have to test for the event type, just for an href to be there -- and it's only available on anchor tags anyway (at least as far as ask() is concerned.)

I was more bothered by the fact that my DCL function was inside the menu builder, so I tested how it'd fare outside of it... Turns out it only added two bytes to the file, so I went along with it. I also managed to save 2 extra bytes by moving the bindEvents part to the end of the DCL function (it was originally at the beginning, which was a flawed idea anyway), so that evened it out.

All in all, 6658 gzipped bytes. I think a couple of days ago, I was at around 6680, so even with these little extra hacks for ask() and $.browser, I'm still winning... :)

Arantor

  • As powerful as possible, as complex as necessary.
  • Posts: 14,278
Re: Remove drafts
« Reply #14, on February 10th, 2013, 06:35 PM »
This one is definitely solved ;)