Feature Request: javascript event for edit mode switch - FogBugz Knowledge Exchange most recent 30 from http://fogbugz.stackexchange.com2013-05-22T05:13:32Zhttp://fogbugz.stackexchange.com/feeds/question/3034http://www.creativecommons.org/licenses/by-nc/2.5/rdfhttp://fogbugz.stackexchange.com/questions/3034/feature-request-javascript-event-for-edit-mode-switchFeature Request: javascript event for edit mode switchKen Morse2010-05-12T18:15:24Z2012-10-02T11:28:02Z
<p>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.</p>
<p>Are there any plans to add custom JavaScript events to FogBugz for cases like this? I think custom events like <em>fbOnBugEdit</em> and <em>fbOnBugView</em> for going into bug edit and bug view modes respectively could be very useful.</p>
<blockquote>
<p><img src="http://www.gravatar.com/avatar/baf927dcc0b0c5d0f41dece1e575aa0f?s=32&d=identicon&r=PG" alt="Fog Creek"> <a href="http://fogbugz.stackexchange.com/questions/1023/whats-that-kiwi-logo-and-case-number-at-the-bottom-of-my-feature-request" rel="nofollow">Case FC2038281</a></p>
</blockquote>
http://fogbugz.stackexchange.com/questions/3034/feature-request-javascript-event-for-edit-mode-switch/3036#3036Answer by JohnFx for Feature Request: javascript event for edit mode switchJohnFx2010-05-12T22:19:52Z2010-05-12T22:19:52Z<p><strong>This isn't exactly pretty, but I'm binding the to ajaxSend method to detect the switch in my plug-in like so:</strong> </p>
<pre><code>var ajaxHandler = function() {
if (isEditMode()) { //raise event }
};
jQuery(window).unbind("ajaxSend", ajaxHandler);
jQuery(window).bind("ajaxSend", ajaxHandler);
</code></pre>
<p><strong>Here is the code I use to check if the page is in edit mode (again, not pretty)</strong> </p>
<pre><code>function isEditMode() {
return ($("textarea[name=sEvent]").length > 0);
}
</code></pre>