0

I have this old "closed" system where it runs IE in its own container, meaning I have to code like a caveman in many cases because I can't use any browser developer tools/console to x-ray the objects being returned from the remote system.

Now, the specific function I'm looking at is a callback from a third party (it gets complicated) that returns what I am willing to bet is a standard JSON object.

function core_OnUeDeltaItemsUpdate(dataType, oData)
{
    if (dataType == "Units")
    {
        // Bail if dispatch report xml hasn't been loaded yet.
        if (oXml == null)
            return;

        ..... does lots of stuff

        // Reload the content in case any of our displayed units changed
        processUeDelta.click();
    }
}

... at the bottom of the page

<button style="display:none;" type="button" id="processUeDelta"/>

and the attached javascript file that I was hoping would use jQuery

$(function(){
    $("#processUeDelta").click(function(){
        var i = 0;
        alert(this.ueDelta);
        for(var propertyName in this.ueDelta)
        {
            i++;
            alert("property " + i + ": " + oData[propertyName]);
        }
    });
});

Now, currently the last function that binds itself to the hidden button cannot parse oData. I'm stuck on two things here.

  1. I'm not sure how to pass the oData object to the attached eventhandler
  2. I'm not too keen on this design, perhaps there is another way were I can take out the intermediary button so I can then process the JSON data object oData.

Points of note:

  • This is based on a data pump, so this callback is being called on an average of 5s.
  • I am limited to using jQuery 1.7.1
  • I cannot see the object, my browser cannot act as a test harness, there are too many moving parts for me to be able to test it from outside the application.
4
  • Are you not able to edit the core_OnUeDeltaItemsUpdate function? Commented Apr 4, 2014 at 22:25
  • @NaNpx that is where I'm playing. If you can see a way to this that I'm not seeing, please, enlighten me Commented Apr 5, 2014 at 22:09
  • If you can update core_OnUeDeltaItemsUpdate then why trigger an event on the hidden button to pass the data? You can just create a function in your jQuery file and call it from core_OnUeDeltaItemsUpdate passing in oData as a parameter. Commented Apr 7, 2014 at 15:06
  • @NaNpx I'm not sure I understand what you mean. My issue with core_OnUeDeltaItemsUpdate is that it is in a different part of the webapp (literally up the stack, closer to the root). So it is the base callback function for many other functions that subscribe to it. Hence, I cannot edit it directly purely for my purpose. Commented Apr 7, 2014 at 15:21

1 Answer 1

1

You can replace the core_OnUeDeltaItemsUpdate function with your own and then call the original core_OnUeDeltaItemsUpdate function. In your jQuery file do something like this

$(document).ready(function(){
    window._core_OnUeDeltaItemsUpdate = core_OnUeDeltaItemsUpdate;

    window.core_OnUeDeltaItemsUpdate = function(dataType, oData){

        // pass the parameters into the original function
        _core_OnUeDeltaItemsUpdate(dataType, oData);

        // do whatever you need to do with oData
        var i = 0;
        alert(this.ueDelta);
        for(var propertyName in this.ueDelta)
        {
            i++;
            alert("property " + i + ": " + oData[propertyName]);
        }
    }
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.