Re: JS Client OM - script only runs in edit mode
Hehe. I figured. I was just joking. My function call has multiple params and also contains an if/else block. If I strip the code right back I can successfully alert the current user info, so I know the context IS being 'got'. I'm sure it'll wind up being a syntactic oversight but this doesn't explain why it would work in Edit mode. :\ On 28 November 2012 10:42, Ishai Sagi wrote: > Sorry – that should have had instructions to replace ViewItem with the > name of your function. > > How about trying to put your function in > > spBodyOnLoadFunctionNames.push( ) > > ** ** > > ** ** > > **[image: Description: Description: C:\Users\Brian\Pictures\EXD > Logos\Extelligent logo no text.jpg]***Ishai Sagi* | Solutions Architect > 0488 789 786 | is...@exd.com.au | www.sharepoint-tips.com | > @ishaisagi<http://twitter.com/ishaisagi> > | MVP Profile <https://mvp.support.microsoft.com/profile/Ishai> > > ** ** > > *From:* ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] *On > Behalf Of *Web Admin > *Sent:* Wednesday, 28 November 2012 10:30 AM > > *To:* ozMOSS > *Subject:* Re: JS Client OM - script only runs in edit mode > > ** ** > > Hi Ishai, > > ** ** > > I get 'ViewItem' is undefined. And it has the added benefit of breaking > editing of the CEWP. :) > > ** ** > > I'd originally tried passing my function in the same way but it made no > difference. > > ** ** > > The script obviously works, just not in browser mode. > > ** ** > > On 28 November 2012 10:09, Ishai Sagi wrote: > > Can you add the following to the page just to test? > > > > ** > > window.onload = function(){ ExecuteOrDelayUntilScriptLoaded(ViewItem, > "sp.js"); }; > > ** > > > > > > > > **[image: Description: Description: C:\Users\Brian\Pictures\EXD > Logos\Extelligent logo no text.jpg]***Ishai Sagi* | Solutions Architect > 0488 789 786 | is...@exd.com.au | www.sharepoint-tips.com | > @ishaisagi<http://twitter.com/ishaisagi> > | MVP Profile <https://mvp.support.microsoft.com/profile/Ishai> > > > > *From:* ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] *On > Behalf Of *Web Admin > *Sent:* Wednesday, 28 November 2012 10:00 AM > *To:* ozMOSS > *Subject:* Re: JS Client OM - script only runs in edit mode > > > > Hi Iain, > > > > I can see why it's failing. It's not getting the context. I just don't why > it's failing in view mode. I assumed the js client resources would be > available by default? > > > > SCRIPT5007: Unable to get value of the property 'get_current': object is > null or undefined [ln 796] > > > > 795 //Get an instance of the Client Content. > > 796 currentContext = new SP.ClientContext.get_current(); > > > > > > > > On 27 November 2012 15:33, Iain Carlin wrote: > > Hi Paul, > > Don't have a direct answer for you, but if you use IE Developer Tools > (F12) you will see what scripts aren't being loaded. > > (I had a similar experience the other day and it was due to an included js > file being checked out - F12 helped me find which one). > > Cheers, Iain > > On 27 November 2012 13:57, Web Admin > wrote: > > Hi all, > > > > I have added some JavaScript to a CEWP on a list view. It runs beautifully > when the page is in edit mode but does nothing when not. > > > > I'm assuming that a required js file is not being loaded in view mode but > am stumped. > > > > I have a script reference to my jQuery lib. This is correct and proven.*** > * > > > > Am I missing something? A reference to sp.js or something else blindingly > obvious? > > > > Regards, > > > > Paul > > > > ___ > ozmoss mailing list > ozmoss@ozmoss.com > http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss > > > > ___ > ozmoss mailing list > ozmoss@ozmoss.com > http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss > > > > > > > > -- > > Regards, > > > > Paul Noone > > > > SharePoint Farm Admin/Developer > Infrastructure Team > CEO Sydney > > p: (02) 9568 8461 > f: (02) 9568 8483 > e: paul.no...@syd.catholic.edu.au &
Re: JS Client OM - script only runs in edit mode
Hi Ishai, I get 'ViewItem' is undefined. And it has the added benefit of breaking editing of the CEWP. :) I'd originally tried passing my function in the same way but it made no difference. The script obviously works, just not in browser mode. On 28 November 2012 10:09, Ishai Sagi wrote: > Can you add the following to the page just to test? > > ** ** > > ** > > window.onload = function(){ ExecuteOrDelayUntilScriptLoaded(ViewItem, > "sp.js"); }; > > ** > > ** ** > > ** ** > > ** ** > > **[image: Description: Description: C:\Users\Brian\Pictures\EXD > Logos\Extelligent logo no text.jpg]***Ishai Sagi* | Solutions Architect > 0488 789 786 | is...@exd.com.au | www.sharepoint-tips.com | > @ishaisagi<http://twitter.com/ishaisagi> > | MVP Profile <https://mvp.support.microsoft.com/profile/Ishai> > > ** ** > > *From:* ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] *On > Behalf Of *Web Admin > *Sent:* Wednesday, 28 November 2012 10:00 AM > *To:* ozMOSS > *Subject:* Re: JS Client OM - script only runs in edit mode > > ** ** > > Hi Iain, > > ** ** > > I can see why it's failing. It's not getting the context. I just don't why > it's failing in view mode. I assumed the js client resources would be > available by default? > > ** ** > > SCRIPT5007: Unable to get value of the property 'get_current': object is > null or undefined [ln 796] > > ** ** > > 795 //Get an instance of the Client Content. > > 796 currentContext = new SP.ClientContext.get_current(); > > ** ** > > ** ** > > ** ** > > On 27 November 2012 15:33, Iain Carlin wrote: > > Hi Paul, > > Don't have a direct answer for you, but if you use IE Developer Tools > (F12) you will see what scripts aren't being loaded. > > (I had a similar experience the other day and it was due to an included js > file being checked out - F12 helped me find which one). > > Cheers, Iain > > On 27 November 2012 13:57, Web Admin > wrote: > > Hi all, > > ** ** > > I have added some JavaScript to a CEWP on a list view. It runs beautifully > when the page is in edit mode but does nothing when not. > > ** ** > > I'm assuming that a required js file is not being loaded in view mode but > am stumped. > > ** ** > > I have a script reference to my jQuery lib. This is correct and proven.*** > * > > ** ** > > Am I missing something? A reference to sp.js or something else blindingly > obvious? > > ** ** > > Regards, > > ** ** > > Paul > > ** ** > > ___ > ozmoss mailing list > ozmoss@ozmoss.com > http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss > > > > ___ > ozmoss mailing list > ozmoss@ozmoss.com > http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss > > > > > > ** ** > > -- > > Regards, > > ** ** > > Paul Noone > > ** ** > > SharePoint Farm Admin/Developer > Infrastructure Team > CEO Sydney > > p: (02) 9568 8461 > f: (02) 9568 8483 > e: paul.no...@syd.catholic.edu.au > w: http://www.ceosyd.catholic.edu.au/ > > ** ** > > ___ > ozmoss mailing list > ozmoss@ozmoss.com > http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss > > -- Regards, Paul Noone SharePoint Farm Admin/Developer Infrastructure Team CEO Sydney p: (02) 9568 8461 f: (02) 9568 8483 e: paul.no...@syd.catholic.edu.au w: http://www.ceosyd.catholic.edu.au/ <>___ ozmoss mailing list ozmoss@ozmoss.com http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
Re: JS Client OM - script only runs in edit mode
Hi Iain, I can see why it's failing. It's not getting the context. I just don't why it's failing in view mode. I assumed the js client resources would be available by default? SCRIPT5007: Unable to get value of the property 'get_current': object is null or undefined [ln 796] 795 //Get an instance of the Client Content. 796 currentContext = new SP.ClientContext.get_current(); On 27 November 2012 15:33, Iain Carlin wrote: > Hi Paul, > > Don't have a direct answer for you, but if you use IE Developer Tools > (F12) you will see what scripts aren't being loaded. > > (I had a similar experience the other day and it was due to an included js > file being checked out - F12 helped me find which one). > > Cheers, Iain > > On 27 November 2012 13:57, Web Admin wrote: > >> Hi all, >> >> I have added some JavaScript to a CEWP on a list view. It runs >> beautifully when the page is in edit mode but does nothing when not. >> >> I'm assuming that a required js file is not being loaded in view mode but >> am stumped. >> >> I have a script reference to my jQuery lib. This is correct and proven. >> >> Am I missing something? A reference to sp.js or something else blindingly >> obvious? >> >> Regards, >> >> Paul >> >> ___ >> ozmoss mailing list >> ozmoss@ozmoss.com >> http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss >> >> > > ___ > ozmoss mailing list > ozmoss@ozmoss.com > http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss > > -- Regards, Paul Noone SharePoint Farm Admin/Developer Infrastructure Team CEO Sydney p: (02) 9568 8461 f: (02) 9568 8483 e: paul.no...@syd.catholic.edu.au w: http://www.ceosyd.catholic.edu.au/ ___ ozmoss mailing list ozmoss@ozmoss.com http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
RE: JS Client OM - script only runs in edit mode
Agreed - the form web part is the correct one for scripts - the CEWB is too picky at what it will allow to run. [Description: Description: C:\Users\Brian\Pictures\EXD Logos\Extelligent logo no text.jpg]Ishai Sagi | Solutions Architect 0488 789 786 | is...@exd.com.au<mailto:is...@exd.com.au> | www.sharepoint-tips.com<http://www.sharepoint-tips.com/> | @ishaisagi<http://twitter.com/ishaisagi> | MVP Profile<https://mvp.support.microsoft.com/profile/Ishai> From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Callum Bundy Sent: Tuesday, 27 November 2012 4:53 PM To: ozMOSS Subject: RE: JS Client OM - script only runs in edit mode I think if you put your JS in a form web part it will be OK in there for future reference. Callum From: ozmoss-boun...@ozmoss.com<mailto:ozmoss-boun...@ozmoss.com> [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Nigel Hertz Sent: Tuesday, 27 November 2012 4:42 PM To: ozMOSS Subject: RE: JS Client OM - script only runs in edit mode I've actually just been doing something like this. As soon as you check in the page, all javascript etc in a CEWP is removed. The way I worked around it is to put everything in a text file, save the text file to a document library, and reference that from the CEWP. My text file is attached (if it makes it to the list) and then when you add the CEWP, the very first option gives you a chance to pull in content from a url - simply insert the url to the text file. From: ozmoss-boun...@ozmoss.com<mailto:ozmoss-boun...@ozmoss.com> [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Web Admin Sent: Tuesday, 27 November 2012 2:27 PM To: ozMOSS Subject: JS Client OM - script only runs in edit mode Hi all, I have added some JavaScript to a CEWP on a list view. It runs beautifully when the page is in edit mode but does nothing when not. I'm assuming that a required js file is not being loaded in view mode but am stumped. I have a script reference to my jQuery lib. This is correct and proven. Am I missing something? A reference to sp.js or something else blindingly obvious? Regards, Paul Stockland Notice: If this communication has been sent to you by mistake, please delete and notify us. If it has been sent to you by mistake, legal privilege is not waived or lost and you are not entitled to use it in any way. Stockland and its subsidiaries reserve the right to monitor e-mail communication through its networks. <><>___ ozmoss mailing list ozmoss@ozmoss.com http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
RE: JS Client OM - script only runs in edit mode
I think if you put your JS in a form web part it will be OK in there for future reference. Callum From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Nigel Hertz Sent: Tuesday, 27 November 2012 4:42 PM To: ozMOSS Subject: RE: JS Client OM - script only runs in edit mode I've actually just been doing something like this. As soon as you check in the page, all javascript etc in a CEWP is removed. The way I worked around it is to put everything in a text file, save the text file to a document library, and reference that from the CEWP. My text file is attached (if it makes it to the list) and then when you add the CEWP, the very first option gives you a chance to pull in content from a url - simply insert the url to the text file. From: ozmoss-boun...@ozmoss.com<mailto:ozmoss-boun...@ozmoss.com> [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Web Admin Sent: Tuesday, 27 November 2012 2:27 PM To: ozMOSS Subject: JS Client OM - script only runs in edit mode Hi all, I have added some JavaScript to a CEWP on a list view. It runs beautifully when the page is in edit mode but does nothing when not. I'm assuming that a required js file is not being loaded in view mode but am stumped. I have a script reference to my jQuery lib. This is correct and proven. Am I missing something? A reference to sp.js or something else blindingly obvious? Regards, Paul Stockland Notice: If this communication has been sent to you by mistake, please delete and notify us. If it has been sent to you by mistake, legal privilege is not waived or lost and you are not entitled to use it in any way. Stockland and its subsidiaries reserve the right to monitor e-mail communication through its networks. ___ ozmoss mailing list ozmoss@ozmoss.com http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss
RE: JS Client OM - script only runs in edit mode
I've actually just been doing something like this. As soon as you check in the page, all javascript etc in a CEWP is removed. The way I worked around it is to put everything in a text file, save the text file to a document library, and reference that from the CEWP. My text file is attached (if it makes it to the list) and then when you add the CEWP, the very first option gives you a chance to pull in content from a url - simply insert the url to the text file. From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of Web Admin Sent: Tuesday, 27 November 2012 2:27 PM To: ozMOSS Subject: JS Client OM - script only runs in edit mode Hi all, I have added some JavaScript to a CEWP on a list view. It runs beautifully when the page is in edit mode but does nothing when not. I'm assuming that a required js file is not being loaded in view mode but am stumped. I have a script reference to my jQuery lib. This is correct and proven. Am I missing something? A reference to sp.js or something else blindingly obvious? Regards, Paul Stockland Notice: If this communication has been sent to you by mistake, please delete and notify us. If it has been sent to you by mistake, legal privilege is not waived or lost and you are not entitled to use it in any way. Stockland and its subsidiaries reserve the right to monitor e-mail communication through its networks. ÿþ<