小编joa*_*mbl的帖子

在Tampermonkey中使用jQuery

我正在使用Chrome 27.0.1453.116 m并启用了"Experimental Javascript",但是我无法让jQuery在Tampermonkey上运行.

我试过了:

// ==UserScript==
// @name       My Fancy New Userscript
// @require    http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// ==/UserScript==

var $ = unsafeWindow.jQuery;
var jQuery = unsafeWindow.jQuery;
Run Code Online (Sandbox Code Playgroud)

但是,我在行var $ = unsafeWindow.jQuery;突出显示unsafeWindow在定义之前使用unsafeWindow时出现错误.如何解决这个问题?

jquery tampermonkey

15
推荐指数
1
解决办法
2万
查看次数

AngularJS应用程序在锚标记中链接/路由与HTML5模式

如何链接到锚A标记中的其他AngularJS应用程序位置?我正在使用HTML5无散列模式,并希望避免让页面实际重新加载.

例如,在非HTML5模式下,我会这样做:

<a href='#/path'>Link</a>
Run Code Online (Sandbox Code Playgroud)

在HTML5模式下,我可以这样做:

<a href='/path'>Link</a>
Run Code Online (Sandbox Code Playgroud)

但这实际上会导致浏览器重新加载新的URL.我也试过使用ng-href/#/path语法,但它们似乎都没有像我想的那样工作.

如何从锚标签正确链接?

angularjs

11
推荐指数
1
解决办法
1万
查看次数

调用AngularJS $ save后没有得到更新的值

伙计们,我使用AngularJS和angular-resource来执行一个非常简单的REST API调用.这是我列出(并创建)消息的页面的JavaScript代码:

(function() {
'use strict';
var messagesApp = angular.module('messagesApp', ['ngResource']);

messagesApp.factory('Message', function($resource) {
    return $resource('/api/messages/:id', {id: '@id'}, {
        query: {method:'GET', isArray:true} });
});

messagesApp.controller('MessagesCtrl',
  function($scope, Message) {
    $scope.messages = Message.query();

    $scope.addMessage = function() {
        $.Dialog({
            'title': 'Add new Message',
            'content': '<p>Enter the <strong>unique</strong> name of the new message.</p><input type="text" id="newMessageName"/><p>Enter the <strong>unique</strong> ID for this message.</p><input type="text" id="newID"/>',
            'draggable': false,
            'overlay': true,
            'closeButton': true,
            'buttonsAlign': 'right',
            'buttons': {
                'save': {
                    'action' : function() {
                        var newMessage = new Message(); …
Run Code Online (Sandbox Code Playgroud)

javascript rest angularjs angular-resource

1
推荐指数
1
解决办法
3528
查看次数