MochiKit now serves as TurboGears widgets in a software package, enabling users to enhance web development capabilities. With these advanced tools, satisfactory results are possible.
If you choose to use tgMochiKit as a standalone widget, the process is simple. TurboGears can integrate the widget on every page, allowing other JavaScript code on the page to utilize the functions of the MochiKit library. To enable this, developers can simply set the following in their application's main configuration: tg.include_widgets = ['turbogears.mochikit']. It's important to note that the mochikit widget object lives in the turbogears module, as TurboGears initializes the widgets package and selects the appropriate MochiKit version based on the application's configuration.
Alternatively, if a JavaScript-enabled widget relies on the MochiKit library, declaring the tgMochiKit widget as a resource by adding it to its javascript class attribute is the way to go. For instance, a small sample widget that utilizes the MochiKit Logging module could be represented as follows:
from turbogears import widgets, mochikit
class LoggingPanelLink(widget.Widget):
template = """open logging pane"""
javascript = [mochikit].
tgMochiKit has been a valuable addition to my toolkit, aiding me in maximizing my use of the MochiKit library in JavaScript development.
Version 1.4.2: N/A