Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Capturing a function

Capturing a function

Scheduled Pinned Locked Moved JavaScript
javascripthtmldatabasewpfwcf
4 Posts 3 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vodstok
    wrote on last edited by
    #1

    I have a page where I need to trigger a function (I'll call hideBox) when another function (which I will call unChecked) is triggered. So let's say unChecked is called when a checkbox is clicked, as soon as unChecked runs, I need hideBox to run as well. The catch here is that i do not have access to the .js that holds the code for unChecked, and even if I did, I know it is being used by several other pages and I can't risk messing them up in the process. To further complicate things, I can't change any of the properties on the element that calls unChecked since the server side code is really picky about that sort of thing (the rest of the functionality breaks if I change any aspect of the input element. Needless to say, I did not write it.) I have tried just binding the event with jQuery, but jQuery actually changes the attribute array in the DOM, which screws up the post-back behavior. I have done this exact thing before, but that was using prototype, which isn't an option here (and was for another company so I can't go back and see what I did). Any ideas?

    ______________________ Oh Hamburgers!

    N G 2 Replies Last reply
    0
    • V Vodstok

      I have a page where I need to trigger a function (I'll call hideBox) when another function (which I will call unChecked) is triggered. So let's say unChecked is called when a checkbox is clicked, as soon as unChecked runs, I need hideBox to run as well. The catch here is that i do not have access to the .js that holds the code for unChecked, and even if I did, I know it is being used by several other pages and I can't risk messing them up in the process. To further complicate things, I can't change any of the properties on the element that calls unChecked since the server side code is really picky about that sort of thing (the rest of the functionality breaks if I change any aspect of the input element. Needless to say, I did not write it.) I have tried just binding the event with jQuery, but jQuery actually changes the attribute array in the DOM, which screws up the post-back behavior. I have done this exact thing before, but that was using prototype, which isn't an option here (and was for another company so I can't go back and see what I did). Any ideas?

      ______________________ Oh Hamburgers!

      N Offline
      N Offline
      Not Active
      wrote on last edited by
      #2

      If you don't have access and can't change anything there is nothing you can do. :rolleyes:


      I know the language. I've read a book. - _Madmatt

      V 1 Reply Last reply
      0
      • N Not Active

        If you don't have access and can't change anything there is nothing you can do. :rolleyes:


        I know the language. I've read a book. - _Madmatt

        V Offline
        V Offline
        Vodstok
        wrote on last edited by
        #3

        Not exactly true; I have been hamstrung in the past like this and was able to capture the function and essentially add functionality to it, but that was a year ago and I sadly have no access to that code.

        ______________________ Oh Hamburgers!

        1 Reply Last reply
        0
        • V Vodstok

          I have a page where I need to trigger a function (I'll call hideBox) when another function (which I will call unChecked) is triggered. So let's say unChecked is called when a checkbox is clicked, as soon as unChecked runs, I need hideBox to run as well. The catch here is that i do not have access to the .js that holds the code for unChecked, and even if I did, I know it is being used by several other pages and I can't risk messing them up in the process. To further complicate things, I can't change any of the properties on the element that calls unChecked since the server side code is really picky about that sort of thing (the rest of the functionality breaks if I change any aspect of the input element. Needless to say, I did not write it.) I have tried just binding the event with jQuery, but jQuery actually changes the attribute array in the DOM, which screws up the post-back behavior. I have done this exact thing before, but that was using prototype, which isn't an option here (and was for another company so I can't go back and see what I did). Any ideas?

          ______________________ Oh Hamburgers!

          G Offline
          G Offline
          Gerben Jongerius
          wrote on last edited by
          #4

          I know of a way that may work, pending on if this hideBox should always override the unChecked when its javascript file is included. You could opt to override the unChecked javascript method as follows:

          var unChecked = (function() {
          var original_unChecked = unChecked;

          original\_unChecked();
          hideBox();
          

          });

          Its not the neatest way to do it but will do what you want.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups