JQuery autocomplete suddenly stopped working - jquery-autocomplete

The autocomplete was working well for months, suddenly it stopped recognizing 'autocomplete' method.
This is the error I'm getting:
JavaScript runtime error: Object doesn't support property or method 'autocomplete'
Default.aspx
Reference to the local js file was working fine.
<script type="text/javascript" src="Scripts/jquery-ui-1.10.3/ui/jquery-ui.js"></script>
Now that it stopped working I tried the online reference, with no avail.
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
Javascript code:
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
];
$("#MyTextBox").autocomplete({
source: availableTags,
minLength: 0,
select: function (event, ui) {
$get("MyTextBox").value = ui.item.value;
}
});

Could it be a race condition? Where is the autocomplete initialization being done? Is it possible that it is now getting run before jQuery-UI is loaded?

There was a bug in one of my js files which was preventing the jquery from loading, my bad.
I removed the error line, and every works fine now.

Related

Electron NodeJS Ag-Grid Cannot Import

In render.js I have
import { Grid } from 'ag-grid-community';
import { tableMethods } from './table.js';
I created my own custom table methods and decided to try ag-grid since mine aren't as fast as theirs (no surprise). Unfortunately, while I could get my own methods loading from my js file by setting
<script type="module" src="render.js"></script>
I cannot get ag-grid to load, I get this error
Uncaught TypeError: Failed to resolve module specifier "ag-grid-community". Relative references must start with either "/", "./", or "../".
I used npm i ag-grid-community -D to install it. I wasn't sure if I needed the -D, so I tried without that and it still shows same error.
*Note - of course I've tried doing what the error message says. But it didn't resolve and the documentation doesn't mention anything about this.
I was able to get this working by adding following before my render.js file
<script src="ag-grid-community.js"></script>
I also disabled type=module once I realized this is probably the intended way to split up rendering scripts, or at least that was my guess.

Getting an iFrameResize not defined error in AngularJS

I am trying to use the code at: https://github.com/davidjbradshaw/iframe-resizer
In my index.html page I have included (and it does load):
<script src="./Scripts/iframeResizer.js"></script>
In my iframe content page I have included:
<script src="iframeResizer.contentWindow.min.js"></script>
My AngularJS controller is:
ajs_module.controller("MyController",
['$scope', '$window', function ($scope, $window) {
$scope.iframeLoadedCallBack = function () {
console.log('Resizing iFrame...');
iFrameResize({ log: true }); // causes: Uncaught ReferenceError: iFrameResize is not defined
}
}])
When the host page loads and tries to resize the iFrame, I get the error:
Uncaught ReferenceError: iFrameResize is not defined
Thanks for any help.
Have you tried doing window.iFrameResize? as it looks like a scoping issue.
Failing that load it in with require js
Angular uses JqLite instead of the normal jquery, probably you need to add jquery before loading the iframeResizer.js script
if you cant access a global function it should be because is not initializated
(check other dependendies but i didnt find anything else in the iframeResize page)

Chrome Extension: Using addEventListener()

In the tutorial for migrating a Google Chrome Extension to Manifest Version 2, I am directed to Remove inline event handlers (like onclick, etc) from the HTML code, move them into an external JS file and use addEventListener() instead.
OK, I currently have a background.html page that looks like this…
<html>
<script type="text/javascript">
// Lots of script code here, snipped
…
</script>
<body onload="checkInMyNPAPIPlugin('pluginId');">
<object type="application/x-mynpapiplugin" id="pluginId">
</body>
</html>
Following another directive, I've moved that Lots of script code into a separate .js file, and following this directive, I need to remove the onload= from the body tag, and instead cal addEventListener() in my script code. I've tried several approaches, but am apparently guessing wrong. What will that code look like? In particular, upon what object do I invoke addEventListener()?
Thanks!
I normally use this for body onload event...
document.addEventListener('DOMContentLoaded', function () {
// My code here.. ( Your code here )
});
For somethings it is working.. but really, I think we should use..
window.addEventListener('load', function () {
document.getElementById("#Our_DOM_Element").addEventListener('change - or - click..', function(){
// code..
});
});

Chrome extension calls to executeScript stop working after downloading a file in a page

An extension I'm working on behaves strangely after the user follows a link that downloads a file.
If I run the following bit of code from a context menu the alert is displayed as expected, and I can call it any number of times and it will work :
chrome.tabs.executeScript(null, { code: "alert('hello')", allFrames: true },
function () {
console.log("alert completed");
});
As soon download a file from that same page, execute script stops working.
Any ideas?
It sounds like a bug to me. You should open an issue on crbug.com.

How to close the current extension tab?

I'm trying to close the Options page of the extension.
I have a Cancel button and I'm using this code:
chrome.tabs.getCurrent(null, function(tab) {
chrome.tabs.remove(tab.id, function() {});
});
When I'm trying to use it, it always gives this error:
Uncaught TypeError: Cannot call method 'getCurrent' of undefined
What's wrong with the code?
It works for me with one little fix:
chrome.tabs.getCurrent(function(tab) {
chrome.tabs.remove(tab.id, function() { });
});
Just make sure you're really running this code in options page of your extension and not just some HTML page, because chrome.tabs API is available only for extensions.
Most likely you're running your code from a content script, where chrome.tabs is undefined. If this is the case, you can instead send a message to the background page and have the background page (which has access to chrome.tabs) make the call.
Note that from a background page, you would use chrome.tabs.getSelected since getCurrent will return undefined.
In the options page, you can just do:
window.close()
If you wanted to use chrome.tabs.getCurrent, do you have tabs defined in the permissions section within the manifest?
I have time to continue my extension after a very long time. I checked the documentation again. So it was a inline script, that I had probably blocked with Content Security Policy in the manifest, because I hadn't read the documentation precisely.
Now Chrome blocks inline scripts by default, so I'll have to fix it anyway.
Only this worked for me:
chrome.tabs.query({ active: true }, function(tabs) {
chrome.tabs.remove(tabs[0].id);
});

Resources