• Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • core
    • 1.424

      The contents of the bind expression, and any further contents of your <script>, are dumped outside of any script block and appear as plain text in the web page.

      Adding <st:adjunct includes="org.kohsuke.stapler.bind"/> first solves that problem, but now your <script> block is not run at all.

          [JENKINS-15617] <st:bind> does not work inside <l:ajax>

          Jesse Glick created issue -

          Jesse Glick added a comment -

          …since as per http://stackoverflow.com/questions/4619668/executing-script-inside-div-retrieved-by-ajax scripts included in dynamically inserted content are not executed. You can work around this in general by using a st:adjunct of your own JavaScript, but this cannot work when st:bind has to produce part of that JavaScript since an adjunct is static.

          Jesse Glick added a comment - …since as per http://stackoverflow.com/questions/4619668/executing-script-inside-div-retrieved-by-ajax scripts included in dynamically inserted content are not executed. You can work around this in general by using a st:adjunct of your own JavaScript, but this cannot work when st:bind has to produce part of that JavaScript since an adjunct is static.

          Jesse Glick added a comment -

          Demo: hpi:run; create job; add demo builder; click Test; nothing happens. Save job (with builder), Configure again; now Test works.

          Jesse Glick added a comment - Demo: hpi:run ; create job; add demo builder; click Test; nothing happens. Save job (with builder), Configure again; now Test works.
          Jesse Glick made changes -
          Attachment New: JENKINS-15617.zip [ 22756 ]

          Jesse Glick added a comment -

          The latter problem is not quite true: <script> is run but in a nonglobal context so any definitions must be prefixed with window. in order to be accessible later.

          Jesse Glick added a comment - The latter problem is not quite true: <script> is run but in a nonglobal context so any definitions must be prefixed with window. in order to be accessible later.

          Code changed in jenkins
          User: Kohsuke Kawaguchi
          Path:
          war/src/main/webapp/scripts/hudson-behavior.js
          http://jenkins-ci.org/commit/jenkins/51f508ba371ee222dced304c4a77a9b1b4ca37db
          Log:
          [FIXED JENKINS-15617]

          Evaluate script in global context.
          See http://perfectionkills.com/global-eval-what-are-the-options/ for how
          to evaluate JavaScript in global context.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Kohsuke Kawaguchi Path: war/src/main/webapp/scripts/hudson-behavior.js http://jenkins-ci.org/commit/jenkins/51f508ba371ee222dced304c4a77a9b1b4ca37db Log: [FIXED JENKINS-15617] Evaluate script in global context. See http://perfectionkills.com/global-eval-what-are-the-options/ for how to evaluate JavaScript in global context.
          SCM/JIRA link daemon made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: Open [ 1 ] New: Resolved [ 5 ]

          Jesse Glick added a comment -

          <st:adjunct assumes="org.kohsuke.stapler.framework.prototype.prototype" includes="org.kohsuke.stapler.bind"/> is actually necessary as the workaround for the first part; otherwise you sometimes get errors in the page like Cannot call method 'select' of undefined since Prototype exists but has no member Selector.

          Jesse Glick added a comment - <st:adjunct assumes="org.kohsuke.stapler.framework.prototype.prototype" includes="org.kohsuke.stapler.bind"/> is actually necessary as the workaround for the first part; otherwise you sometimes get errors in the page like Cannot call method 'select' of undefined since Prototype exists but has no member Selector .

          Jesse Glick added a comment -

          Simpler still: <st:adjunct assumes="org.kohsuke.stapler.bind"/>

          Jesse Glick added a comment - Simpler still: <st:adjunct assumes="org.kohsuke.stapler.bind"/>
          Jesse Glick made changes -
          Assignee Original: Jesse Glick [ jglick ] New: Kohsuke Kawaguchi [ kohsuke ]

            kohsuke Kohsuke Kawaguchi
            jglick Jesse Glick
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: