I am trying to open a jquery dialog from my chrome extension. There are several posts about this, not all of them are related to my needs.
I found this one that claims to have working code. I tried to use this method in my extension without success.
In my extension on the background, I send a message to the content script as follows:
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){ chrome.tabs.sendMessage(tabs[0].id, {action: "open_dialog_box"}, function(response) { }); });
and in the content of the script I put the code that I copied almost as it is (Sorry for that, but just for the sake of the nail radius I wanted to get as close to the original as possible to find out that I was messing up though):
chrome.extension.onMessage.addListener(function(msg, sender, sendResponse){ if (msg.action == 'open_dialog_box') { alert("Message recieved!"); var layerNode= document.createElement('div'); layerNode.setAttribute('id','dialog'); layerNode.setAttribute('title','Basic dialog'); var pNode= document.createElement('p'); console.log("pNode created"); pNode.innerHTML = "something"; layerNode.appendChild(pNode); document.body.appendChild(layerNode); jQuery("#dialog").dialog({ autoOpen: true, draggable: true, resizable: true, height: 'auto', width: 500, zIndex:3999, modal: false, open: function(event, ui) { $(event.target).parent().css('position','fixed'); $(event.target).parent().css('top', '5px'); $(event.target).parent().css('left', '10px'); } });
Now a warning appears, so I know that the message has appeared, but the dialog does not open.
Can you please suggest what is wrong here?
EDIT:
As per Brock's request, here is my manifest:
{ "name": "Dialog test", "version": "1.1", "background": { "scripts": ["contextMenus.js"] }, "permissions": ["tabs", "<all_urls>", "contextMenus"], "content_scripts" : [ { "matches" : [ "http://*/*" ], "js": ["jquery-1.8.3.js", "jquery-ui.js"], "css": [ "jquery-ui.css" ], "js": ["openDialog.js"] } ], "manifest_version": 2 }