Uploaded image for project: 'OODT (Retired)'
  1. OODT (Retired)
  2. OODT-375

Improve ApplicationResponse::includeJavascript to support including JavaScript snippets in addition to static files

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 0.3
    • 0.4
    • balance
    • None

    Description

      Currently, ApplicationResponse::includeJavascript only accepts a string which is interpreted as the url to the JavaScript resource to include. That string is then injected as the 'src' attribute of a '<script type="javascript">' block.

      Occasionally it is necessary to make some information (e.g.: a module's environment information) available to any client-side JavaScript libraries that might need to make use of it. Because this information is dynamic, the current format is restrictive as it only accepts urls to static file resources. This issue proposes changing the method signature in a way that maintains complete backwards compatibility, but further allows a developer to pass arbitrary JavaScript to the client. The new signature should be something like:

      public function includeJavascript( $src, $isRaw = false );
      

      The default behavior (that of providing a URL to a static resource to include) is unchanged as the $isRaw attribute defaults to false if omitted. If a developer explicitly passes Boolean true as the second parameter, however, the contents of $src will be placed in the body of the '<script type="javascript">' block, instead of as its 'src' attribute.

      Attachments

        Activity

          People

            ahart Andrew Hart
            ahart Andrew Hart
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: