Storing a Reference to the Document Object when the Office App initializes
hello,
i'm trying create task pane app excel , utilizing msdn article http://msdn.microsoft.com/en-us/magazine/jj891051.aspx.
the article suggest store reference mentioned in title. problem new javascript think missing simple in encapsulation.
the errors methods app.initialization() or app.get_document(office.document.context) don't exist.
i appreciate help.
/// <reference path="../app.js" /> /// <reference path="../office.js" /> /// <reference path="~/scripts/office/1.1/excel-web-16.00.debug.js" /> /// <reference path="~/scripts/office/1.1/office-vsdoc.js" /> (function () { "use strict"; // initialize function must run each time new page loaded office.initialize = function (reason) { //display initialization reason. if (reason == "inserted") write("the app inserted"); if (reason == "documentopened") write("the app part of document."); //function writes div id="message" on page. function write(message) { document.getelementbyid('message').innertext += message; } $(document).ready(function() { app.initialize(); //store reference document object when app initializes app.get_document(office.context.document); } //use self-executing anonymous function encapsulate functionality app uses var app = (function () { var _document; function get_document(officedocument) { _document = officedocument; } // other fields , functions associated app return { get_document: get_document //other exposed members }; }); })();
john donnelly
hi john,
i noticed define app object in function below:
office.initialize = function (reason) {}after move outside function below:
/// <reference path="../app.js" /> (function () { "use strict"; // initialize function must run each time new page loaded office.initialize = function (reason) { $(document).ready(function () { // app.initialize(); app.get_document(office.context.document); }); }; //use self-executing anonymous function encapsulate functionality app uses var app = (function () { var _document; function get_document(officedocument) { _document = officedocument; } // other fields , functions associated app return { get_document: get_document //other exposed members }; })(); })();
i can use function app.get_document. , since have redefined app , there no method in object, can’t use function app.initialize() anymore.
you can more detail apps office link below:
best regards
fei
we trying better understand customer views on social support experience, participation in interview project appreciated if have time. helping make community forums great place.
click here participate survey.
Microsoft Office for Developers , Apps for Office and SharePoint > Developing Apps for Office 2013
Comments
Post a Comment