1

I have code (http://jsfiddle.net/bug0r/94h3a/17/)

There is error when data loading by rest.api - Object #<Object> has no method 'resolve'

Could you help to find an error?

ember - https://raw.github.com/emberjs/ember.js/release-builds/ember-1.0.0-rc.3.js

    

var A = window.App = Ember.Application.create({
    VERSION: '1.0',
    rootElement: '#appRoot',
    LOG_TRANSITIONS: true
});
A.deferReadiness(); // do not initialize it until we are ready

A.Adapter = DS.RESTAdapter.extend({
    namespace: 'api',
    url: 'http://bug0r.apiary.io'
});
A.Adapter.map('Semantic', {
    primaryKey: 'Key'
});
A.Store = DS.Store.extend({
    revision: 12,
    adapter: A.Adapter
});

A.Router.map(function () {
    // each call will create Ember.Route instance for customizing route
    this.resource("semantic", {
        path: "/"
    });
    this.route("about", {
        path: "/about"
    });
    this.route("favorites", {
        path: "/favs"
    });
});

A.SemanticRoute = Ember.Route.extend({
    model: function () {
        return A.Semantic.find();
    }
});

/* Symantic model*/
A.Semantic = DS.Model.extend({
    Key: DS.attr('string'),
    Name: DS.attr('string'),
});

A.advanceReadiness(); // ready for initialization



How to display popup for each url using page action?

I need some guide on how to achieve this kind of thing.

The thing I want to do is to use page_action to display popup for specific URLs. What I want to achieve is something like this:

When a user loads url in the browser, an AJAX request is sent to my service to check for the url. If url is found on my service, say I will return some text against it. That text will then be displayed in the popup.

For that I am using chrome.tabs.onUpdated.addListener function. The problem with it is that whenever a user opens a new tab, this function is called, it then updates the popup page, removing the message for the previously opened tab.

Any solution?

Update: I am pasting my code, could someone please check what could be the problem?

manifest.json

{
    "manifest_version" : 2,

    "name" : "Know your cashback for a site!",
    "version" : "1.0",
    "description" : "Find out about the cashback of the visiting website right in your browser",

    "background" : { "scripts" : ["jquery.js","records.js"]},
    "permissions" : [ "http://*/*", "https://*/*", "tabs" ],    

    "page_action" : {
                    "default_icon"  : "images/icon.png"
                    }
}

records.js

var result;
function checkForValidUrl(tabId, changeInfo, tab) {
    if (tab.url !== undefined && changeInfo.status == "complete") {
            $.ajax({
            url: 'http://localhost/chrome_extension/index.php',
            data: "url=" + encodeURIComponent(tab.url),
            type:'GET',
            success: function(resp) {
                    if(resp=="not_found"||resp=="invalid_request") {
                        // do nothing
                    } else {
                        resp = JSON.parse(resp);
                        chrome.pageAction.show(tabId);
                        chrome.pageAction.setTitle({
                                                   tabId: tabId,
                                                   title: resp.cashback
                                                   });
                        chrome.pageAction.setPopup({
                                                   tabId: tabId,
                                                   popup: "popup.htm"
                                                   });
                        window.result = resp;
                        //alert('update successful');
                    }               
                }
            });
    }
};

// Listen for any changes to the URL of any tab.
chrome.tabs.onUpdated.addListener(checkForValidUrl);

popup.htm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<span id="request"></span>
<a href="#" id="ref_link"></a>
</body>
</html>

popup.js

var BGPage = chrome.extension.getBackgroundPage();
if(typeof BGPage.result !== undefined) {
document.getElementById('request').innerHTML = BGPage.result.cashback;
document.getElementById('ref_link').href = BGPage.result.store;
}

$('a#ref_link').on('click', function(e) {
    var href = e.currentTarget.href;
    chrome.tabs.query({active:true}, function (tab){
        chrome.tabs.update(tab.id, {url: href});
    });
});
4

1 回答 1

4

在小提琴中,您将 ember-rc3 与 ember-data latest 结合使用。我认为它们不兼容。因此,也尝试使用 ember-latest,它应该可以工作。

编辑:最新的 ember 版本是http://builds.emberjs.com.s3.amazonaws.com/ember-latest.js 最新的 ember-data 版本是http://builds.emberjs.com.s3.amazonaws.com /ember-data-latest.js

小心这些构建是最后一个成功的构建,通过了所有测试,但不保证它们没有错误。

于 2013-04-30T13:30:00.860 回答