Object #<HTMLDivElement> has no method 'setCapture' - google-maps

After making a change to some Google Maps code, I started getting the following error whenever I attempt to click-drag the map:
Uncaught TypeError: Object # has no method 'setCapture'
Google turned up no results for this error, so I though I'd create this question.

Can you show your code??
Recently I'm having an error likely yours. I'm doing this, in my javascript code:
var components = $(".comp-div");
for ( var i = 0; i <= components .size(); i++) {
components[i].css("width"));
}
When you use [] to access an item in a jQuery array, you get the DOM element not a jQuery object, probably you are doing this or something like, so it doesn't have any jQuery methods or any google-maps method.
I changed to use .eq() function, see next example:
var components = $(".comp-div");
for ( var i = 0; i <= components .size(); i++) {
components.eq(i).css("width"));
}

Related

adding a new class using a for loop to determine which class specifically to add

I made this account to ask this question because researching strings and testing a whole ton of different things ended up with nothing working. You should be able to see what I am trying to do with this code piece here that is not working for me. If I hard type out "Level1" instead of "Level[i]" everything works fine.
for (var i = 0; i<=100; i++)
{
if (levelOn == i)
{
var Lv:Level[i] = new Level[i];
addChild(Lv)
}
}
I have 100 level files labeled "level1", "level2", etc in the project folder. I am trying to access a certain level via using a forloop to add a certain level to the screen (levelOn = 56 means the compiler would add the class "Level56" to the screen.)
I think I have the right idea but I cannot get it to work, all I get is this error
Line 24 1086: Syntax error: expecting semicolon before leftbracket.
If someone has a more efficient way of accessing a "level" in a application (where it has the same base class but minor differences) please send me in the right direction.
Thanks!!!!!
Try this:
var i:int;
var Lv:Level[i] = new Level[i];
addChild(Lv)
for (i=0; i<100; i++){
if(LevelOn=i)
}

Error with custom Search and Replace function for Google Sites

I'm trying to use a script to replace a particular string with a different string. I think the code is right, but I keep getting the error "Object does not allow properties to be added or changed."
Does anyone know what could be going wrong?
function searchAndReplace() {
var teams = SitesApp.getPageByUrl("https://sites.google.com/a/directory/teams");
var list = teams.getChildren();
list.forEach(function(element){
page = element.getChildren();
});
page.forEach(function(element) {
var html = element.getHtmlContent();
html.replace(/foo/, 'bar');
element.setHtmlContent = html;
});
};
Try This:
Javascript reference:
The replace() method returns a new string with some or all matches of a pattern replaced by a replacement.
I think the issue here is that forEach cannot change the array that it is called upon. From developer.mozilla.org "forEach() does not mutate the array on which it is called (although callback, if invoked, may do so)."
Try doing it with a regular loop.

Referencing binding annotations dynamically in Polymer 1

I'm trying to set up a function in Polymer 1.0 which will allow a JSON response to tell my application which {{BindingVariable}} in which to insert the response. Unfortunately, the syntax for referencing these binding variables seems to be similar to this:this.BindingVariable, which doesn't allow for dynamic variable names.
What I really need is a way to reference these dynamically like how we can reference anything else in the DOM/PolyDOM. For example: document.querySelector('#'+elementID).
Is there any way to reference binding annotations dynamically? I've searched through the entire Polymer DOM and can't find them listed anywhere even though I know they're in the page.
example
app._onResponseRetrieved = function(e) {
for (var key in e.detail.response) {
// none of these work, but they demonstrate what I'm trying to accomplish
// this.key = e.detail.response[key];
// this.querySelector(key) = e.detail.response[key];
// window[key] = e.detail.response[key];
// document[key] = e.detail.response[key];
// Polymer.dom(key) = e.detail.response[key];
}
JSON Sent to _onResponseRetrieved
{"contactFormOutput":"Success!"}
Binding Annotation in index.html
<div>{{contactFormOutput}}</div>
this[key] = e.detail.response[key];
Javascript allows [] on any object for dynamic property referencing

CodeMirror textarea.getAttribute is not a function error in mvc3 application

I'm using CodeMirror in my ASP.NET MVC 3 application,
CodeMirror's version is up to date(2.34)
my textarea looks like this:
#Html.TextAreaFieldFor(s => s.Data.CodeBehind, htmlAttributes: new Dictionary<string, object> { { "class", "textbox codeBehind nffp-code" } })
I use CodeMirror like this:
var a = CodeMirror.fromTextArea($code, {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-csharp"
});
where $code is
var $code = jQuery('.nffp-code', $root);
And after page load I have this error:
TypeError: textarea.getAttribute is not a function
codemirror.js
Line 2209
textarea.getAttribute("autofocus") != null && hasFocus == document.body;
I used this manual for using CodeMirror:
manual
Even thought, I'm a total noob in JS, I guess it's hard to do it wrong, still I did.
Any Ideas how to fix the problem?
You need to use document.getElementById() instead of the jQuery lookup.
document.getElementById('contents'); //returns a HTML DOM Object
var contents = $('#contents'); //returns a jQuery Object
In jQuery, to get the same result as document.getElementById(), you can access the jQuery Object and get the first element in the object (Remember JavaScript objects act similar to associative arrays).
var contents = $('#contents')[0]; //returns a HTML DOM Object

Accessing DOM object properties from Chrome's content script

I ran into a strange problem with a content script. The content script is defined as "run_at" : "document_end" in the manifest. After a page is loaded the script inserts an object tag into the page (if the tag with predefined id does not exist yet), and sets some properties in it, such as type, width, height, innerHTML, and title. All works fine here.
function checkForObject()
{
var obj = document.getElementById("unique_id");
if(obj == null)
{
var d = document.createElement("object");
d.id = "unique_id";
d.width = "1";
d.height = "1";
d.type = "application/x-y-z";
d.title = "1000";
d.style.position = "absolute";
d.style.left = "0px";
d.style.top = "0px";
d.style.zIndex = "1";
document.getElementsByTagName("body")[0].appendChild(d);
}
}
checkForObject();
I see the new object in the page html-code with proper values in its properties.
Some time later I need to read the title property of the object in the same content script. The code is simple:
function ReadTitle()
{
var obj = document.getElementById("unique_id");
var value = obj.title; // breakpoint
console.log(value);
// TODO: want to use proper title value here
}
The function is called from background.html page:
chrome.tabs.onActivated.addListener(
function(info)
{
chrome.tabs.executeScript(info.tabId, {code: 'setTimeout(ReadTitle, 250);'});
});
Unfortunately, in ReadTitle I'm getting not what I expect. Instead of current value of the title I see the logged value is:
function title() { [native code] }
If I set a breakpoint at the line marked by // breakpoint comment, I see in the watcher that all object properties including the title are correct. Nevertheless, the variable value gets the abovementioned descriptive string.
Apparently, I have missed something simple, but I can't figure it out.
The answer. It was a bug in the npapi plugin, which hosts the object of used type. My apologies for all who have read the question with intention to help.
The NPAPI plugin used in the object erroneously reported title as supported method.