none
How to feed data from one Script Editor Web Part to another on the same page? RRS feed

  • Question

  • I have some javascript that I've put together with help from others in this forum. One block is defined strictly javascript and jquery, and is defined within script tags looking like this:

    <script type="text/javascript" ></script>

    and the second code block's tags look like this:

    <script type="text/ecmascript" ></script>

    individually they seem to work fine when tested individually and the first block retrieves some data and saves it in a hidden field, on the page. The second block is supposed to listen for an onchange event to the hidden field updated by the first block of code. I have tried unsuccessfully to try to put both blocks of code into the same block of code, in a Script Editor web Part and I keep having issues, with syntax, so I'm assuming I can't put both blocks of code in the same block.

    My problem is when I put each block of code in different Script Editor Web Parts the first block of code saves the value into the hidden field, but the onchange event on the hidden field doesn't seem to fire so the second block of code never gets called.  

    I think this would normally be possible on a regular web page, but I don't think I'm fully grasping all of the sharepoint 2013 elements that need to be aligned to get this to work.

    Thanks in advance for any help you may offer.

    Henry

    Thursday, March 9, 2017 9:24 PM

Answers

  • Hi Henry,

    Please add the two blocks code into one block.

    The code structure like this:

    <script src="//code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function(){		
    	//some code. 
    });
    
    ExecuteOrDelayUntilScriptLoaded(RetrieveWebParts, "sp.js");
    function RetrieveWebParts(){
    	//some code
    }
    </script>

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Friday, March 10, 2017 8:25 AM
    Moderator

All replies