SharePoint 2013, unable to set property 'control' .load() - javascript

I have customized a master page in SP 2013, adding a jquery library(vs:1.11.3) to the .html master page as well as some custom script for pulling in HTML content.
Custom Code reference in master page:
$(document).ready(function() {
$('#sideNavBox').empty().load('https://pageiampullingin.html');
$('#sideNavBox').css('display', 'block');
});
The page I'm pulling in has its own script links that act on the DOM elements for the page I'm pulling in. This code works, even though I'm getting an error:
"Unable to set property 'control' of undefined or null reference".
When I hit F12, occurs under ScriptResource.axd, {Sys.UI.Control ... a.control=this}. I've tried different methods for .load() but still getting this error. Again, HTML is pulled in and script works but can't figure out this error. When I block the .load function, the error goes away. Any help would be appreciated.

This line is causing that error: $('#sideNavBox').empty()
Not sure what you are trying to achieve. Remove the line and check. The error should be gone.

I know this is old but...
He's trying to replace the sharepoint left nav with custom content. I'd try this.
$('#sideNavBox').html("").load('https://pageiampullingin.html');

Related

TinyMCE plugin creation callback not running until second load

I am attempting to add in a third party plugin to TinyMCE that is built to connect language-tool and TinyMCE. The plugin will load and work properly only after the second time the page is loaded. The plugin is properly created here
tinymce.PluginManager.add('languagetool', function(editor, url) {
and added to the TinyMCE plugin list here
config.plugins = 'languagetool link lists paste';
When loading the page the first time, I receive the following error.
Uncaught TypeError: Cannot set property 'onload' of null
TinyMCE does not load the editor box at all. After switching to a different page and back, the error no longer appears but the TinyMCE editor (with some plugin functionality) is now visible and is able to be used.
Without seeing running code it will be difficult for anyone to give you a specific thought on why this is happening. Any time I see:
Cannot set property 'xxxxxxx' of null
...this typically means that some code assumes a variable has a value when its null. For example I could try to execute:
tinymce.activeEditor.getContent();
...but if there is no active editor then tinymce.activeEditor is null and you can't execute the getContent() on null. In your scenario some part of the code is trying to run the onload method but the object on which that is being called is null.
You need to figure out what line of code is causing that and then figure out why a variable is null when it is expected to be something else.

JQuery .children() not returning dynamically added elements?

I am integrating a live chat functionality and I am trying to use a JQuery statement to get the chat session ID from a div ID that is not created until a chat is started. (It is dynamically added to the page.) Of course logically, I am making sure that I don't try to select the element until after a chat has started and it exists. Here is the relevant HTML structure and the line of code that I am using:
HTML:
<!--These do not exist until a chat is started-->
<div class="customer_inner_widget">
<div id="chat-session-5748220" style="height:100%;">
JQuery:
$(".customer_inner_widget").children().first().attr("id").split("-")[2]
The strangest thing is that under normal circumstances either when I run it in my script upon closing the chat OR I run it in Google Chrome Developer Tools Console AFTER a chat has started, it does not work:
Output:
Uncaught TypeError: Cannot read property 'split' of undefined
at <anonymous>:1:58
...but If I simply right click on the chat window on my page and select "inspect", then run the same line of code in the console... it works:
Output:
"5748220"
How does just inspecting the HTML wilth Chrome suddenly cause it to work...? How can I perform this hidden magic in my script?
So the issue seems to have something to do with the fact that the child I am trying to access is located within an iFrame and apparently you cannot access external dynamically added content within an iFrame. I guess that JQuery just becomes aware of what is inside after inspecting since it is being forced to discover the elements.

Error when using foundation.core.js

I am trying to put some dropdown buttons on my site (doc : http://foundation.zurb.com/sites/docs/dropdown.html). I got it to work by just putting foundation.min.js on my page but that includes all of the plugins and is pretty large. I am trying to set it up by loading individual plugins according to the documentation : http://foundation.zurb.com/sites/docs/javascript.html.
I am loading foundation.core.js and after that I'm also loading the keyboard util, box util, and dropdown plugin.
This is the error that I get..
Uncaught TypeError: Cannot read property '_init' of undefined
This error is occuring on line 245 of foundation.core.js. It happens even when I just load jQuery and foundation.core.js with no other Foundation files.
Anyone have any ideas as to what is causing this and how to fix it?
Try inserting foundation.util.mediaQuery after foundation.core. The two scripts have a co-dependency.

Loading a Google Charts example with XMLHttpRequest turns the page white

We have a page which uses XMLHttpRequests and tries not to reload the page at all. After the user has logged in it should load a chart. Here is the main page: http://pastebin.com/h55Vzuvy
Here is what we are loading as the chart: http://pastebin.com/zDZr3bb6
I realize that the code where the function is called to load chart.php isn't displayed here but it is working properly and simply calls the xmlhttpGet function in the header of the main page.
The page that loads does evaluate Javascript, as I can put an alert and it pops up but the graph simply doesn't load. Any ideas why?
Also, the Chrome JS Debugger says this when I click to load the chart file. I have triple checked to make sure that the div name is being passed to the variables and the error only happens when loading the chart page.
Uncaught TypeError: Cannot set property 'innerHTML' of null
sethtml
callBackFunction
xmlHttpReq.onreadystatechange
Looks good at first glance, but this line:
document.getElementById(div).innerHTML=content;
Looks like it's where you're having the problem. Most likely 'div' (the id which should be 'auth_status' at this point) is not set right or the DOM was modified and busted up the auth_status div.
I'd recommend testing with:
console.log("id: " + div);
on the line right before that (so, line 66). If that shows "auth_status" as the ID like you'd expect, then I'd try typing this in the firebug/chrome js console:
document.getElementById(div)
to make sure it's still in the DOM. Good luck!

IE7 gives error

I have one page which have chat application,wall comments,uploading photos,videos on that page.All is working fine on mozilla firefox,chrome but does not work on IE7.It gives two error
jquery-1.4.4.min.js
HTML Parsing error.Unable to modify
the parent container element before
the child element is closed
(KB9278917).
Because of this error my rightside bar of this page is not seeing & chat application is also not working.
Please reply me as early as possible.
Thank you
This question discusses the error message you have listed as (2).
You're modifying document while it's being loaded (when browser hasn't "seen" closing tag for this element) . This causes very tricky situation in the parser and in IE it's not allowed.
Since you're using jQuery, you can probably avoid this by putting whatever code is causing this error in a function called once the page is loaded, using the jQuery.ready function:
<script>
jQuery.ready(function() {
// put your code here, instead of just inside <script> tags directly
});
</script>

Categories