7

3

FogBugz currently switches between "bug edit" mode and "bug view" modes using Ajax transformations (rather than page loads). Because of this, there's currently no way to tell from JavaScript which mode FogBugz is in without constantly checking via a timer.

Are there any plans to add custom JavaScript events to FogBugz for cases like this? I think custom events like fbOnBugEdit and fbOnBugView for going into bug edit and bug view modes respectively could be very useful.

Fog Creek Case FC2038281

flag
FogCreek has indicated in the past (not sure where) that they do not plan on having any sort of a javascript API due to having to support and maintain it once they start down that path. Just FYI. – cdeszaq May 13 2010 at 16:08
@adambox not a property but an event; looks like BugViewChange is what he needs? – Michel de Ruiter Sep 14 at 7:10
Ken, do you mean editing existing events using the Case Event Edit plugin? – Michel de Ruiter Sep 19 at 7:04
@Michel: no, I'm talking about actual javascript events on the page itself. If you're trying to programmatically determine if the page is in view more or edit mode, you currently need to use a timer and continuously check; custom js events could prevent this. – Ken Morse Sep 25 at 14:52
@Ken have you tried this, as used elsewhere on this site? $(window).on('BugViewChange', function() { alert('change!'); }); – Michel de Ruiter Oct 2 at 11:25
show 1 more comment

1 Answer

3

This isn't exactly pretty, but I'm binding the to ajaxSend method to detect the switch in my plug-in like so:

var ajaxHandler = function() { 
                     if (isEditMode()) { //raise event } 
                  };

jQuery(window).unbind("ajaxSend", ajaxHandler);
jQuery(window).bind("ajaxSend", ajaxHandler); 

Here is the code I use to check if the page is in edit mode (again, not pretty)

function isEditMode() {
    return ($("textarea[name=sEvent]").length > 0);
}
link|flag
Nice John! I still think having the core FB code fire custom events at the appropriate time would be cleaner though... – Ken Morse May 13 2010 at 11:26
Absolutely. In fact in my code I have a comment right over this code that says "This is a temporary workaround until FC adds an event to trap this in Fogbugz." =) – JohnFx May 13 2010 at 12:58
Won't this get triggered for every ajax call, not just when a page switches between edit/view mode? Seems like it would be good to store the previous edit mode setting and then only raise the edit event if edit mode after the ajax call is different from edit mode cached prior to the call. – Samuel Neff Apr 15 2011 at 13:50

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.