0

I'm trying to implement a simple textbox in a backbone.js application. The user will enter a price in a textbox and hit enter. When the enter key is pressed I get the following error and the page redraws itself. It's as if I hit enter in the url textbox in the browser itself.

I'd like to disable this (i.e. perhaps ev.preventDefault();) but I'm not clear on how to stop this behavior. When I navigate back to the part of the application that now has the textbox the keydown event appears to be hijacked but at least the page doesn't redraw.

background.js:153 Uncaught TypeError: Cannot read property 'onUpdated' of undefined(anonymous function) @ background.js:153 finder.groups.min.js:213Thumbnails setupQuery called: undefined

Below is line 153 in background.js:

chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) {
    if ( changeInfo.status == "complete" ) {
        if (isAsanaUrl(tab.url) == true) {
            goGetIt();
        }
    }  
}); 
halfer
  • 19,824
  • 17
  • 99
  • 186
mba12
  • 2,702
  • 6
  • 37
  • 56

1 Answers1

1

As content script has its own limitations,

chrome.tabs is only available in background scripts and popup scripts.

If you wanna to use chrome.tabs then pass message from content_script to background script and play with chrome.tabs.

chrome.tabs returns undefined in content script

Community
  • 1
  • 1
Alizoh
  • 1,562
  • 1
  • 13
  • 16