小编Mus*_*sar的帖子

如何使用jQuery生成动态ID?

我想将渐进式 id 添加到无序 HTML 列表中的一系列元素。我使用 jQuery.each()方法来获取每个<li>List 并<span>在每个<li>. 然后我添加了带有 each() 索引的 ID 属性作为数字。

$('#menu li ul li').each(function(i, e){
    $(this).append('<span class="arr"></span>');
    $(".arr").attr("id", "id_" + i);
});
Run Code Online (Sandbox Code Playgroud)

Fiddle Demo

但我得到id_3了所有元素。为什么?我做错了什么?

谢谢你的帮助!

javascript jquery

5
推荐指数
2
解决办法
3万
查看次数

如何在Django中使用管道压缩特定文件?

我里面有很多CSS文件SITE_ROOT/sources/css,我想在SITE_ROOT/static/css使用django-pipeline时只压缩一个文件.

STATIC_ROOT = os.path.join(SITE_ROOT, 'static')

STATICFILES_DIRS = (
    os.path.join(SITE_ROOT, 'sources'),
)

PIPELINE_CSS = {
    'responsive': {
        'source_filenames': (
          'css/smartphones.css',
          'css/tablets.css',
        ),
        'output_filename': 'css/responsive.min.css',
    }
}
Run Code Online (Sandbox Code Playgroud)

运行后,collectstatic我在static/文件夹中看到了缩小文件(responsive.min.css),但是还有一个位于该sources/文件夹中的所有文件的副本和一个django管理静态文件的副本.如何只获取STATIC_ROOT文件夹中的缩小文件?

python django

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

如何将无限参数和一个或两个参数传递给JavaScript函数?

如何将多个且无限制的arguments一个或两个参数传递给函数?

例:

function myFunction(_id, _class, arg1, arg2, arg3, arg4, etc...){
    console.log($(_id).html());
    console.log($(_class).html());

    for(var i = 0; i < args.length; i++) {
        alert(args[i]);
    }
}

myFunction("#myDiv",".mySpan", "Hello World!", "Bonjour le monde!", "Hola mundo!", "Ciao mondo", "Hallo Welt!", "etc");
Run Code Online (Sandbox Code Playgroud)

javascript jquery

4
推荐指数
2
解决办法
1430
查看次数

ValueError:使用<pipeline.storage.PipelineCachedStorage对象>找不到该文件

我正在尝试使用Django 1.6.3上的django管道编译SASS并压缩CSS文件,但在访问我的网站后出现以下错误:

ValueError:使用<pipeline.storage.PipelineCachedStorage对象0x0585DF50>找不到文件'css/test2.css'.

我配置的管线上的导以下readthedocs.org:我添加管道INSTALLED_APPS然后我定义STATIC_URLSTATIC_ROOT:

STATIC_URL = '/test/forum/skins/default/media/'
STATIC_ROOT = '/test/forum/skins/default/media/'
Run Code Online (Sandbox Code Playgroud)

文件夹树:

  • 测试
    • 论坛
        • 默认
          • 媒体(静态文件)
            • CSS
            • JS
            • 图片
        • SITE1
        • 站点2
        • site3
  • 意见
  • utils的
  • settings.py

我添加SASSCompilerPIPELINE_COMPILERS然后添加了要压缩的文件的路径:

# pipeline settings
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
PIPELINE_COMPILERS = (
  'pipeline.compilers.sass.SASSCompiler',
)
PIPELINE_CSS = {
    'main': {
        'source_filenames': (
          'css/test.scss',
        ),
        'output_filename': 'css/test2.css',
    },
}
Run Code Online (Sandbox Code Playgroud)

最后我将css链接到我的XHTML索引:

{% load compressed %}
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        {% compressed_css 'main' %}
    </head> …
Run Code Online (Sandbox Code Playgroud)

python django

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

pgAdmin III:拒绝访问数据库

我正在尝试从pgAdmin III连接到远程数据库.我创建了" 新服务器注册 ".当我连接到数据库时,我得到"访问数据库被拒绝".

在此输入图像描述

我设置正确.这些是我的PostgreSQL设置:

  • pg_hba.conf >

PostgreSQL客户端身份验证配置文件

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             postgres                                trust
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
host    all             all             192.168.0.0/16          md5
Run Code Online (Sandbox Code Playgroud)
  • postgresql.conf >我允许所有的连接listen_addresses = '*'

使用SSH我可以连接到数据库:

[fuiba@test]$ psql …
Run Code Online (Sandbox Code Playgroud)

postgresql

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

省略号应用于文本时如何显示工具提示?

我尝试使用以下代码:

$('td').bind('mouseenter', function(){
    var $this = $(this);
    if(this.offsetWidth < this.scrollWidth){
        var text = $this.text();
        $this.attr("data-title",text);
        $this.tipper({
            direction: "bottom",
            follow: true
        });
    }
});
Run Code Online (Sandbox Code Playgroud)

的jsfiddle

工作正常,但不是第一次,有必要再次鼠标移动,以使其工作.
任何帮助是极大的赞赏!谢谢!

PS.我不想插入data-title内联.

javascript jquery

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

为什么Java变量无法在IF语句中解析?

<%
    if (group.isControlPanel()) {
        String cssClassContainer = "container";
    } else {
        String cssClassContainer = "container-fluid";
    }
%>
Run Code Online (Sandbox Code Playgroud)

我在If语句中定义变量时出现编译错误: An error occurred at line: 40 in the jsp file: /page.jsp__cssClassContainer cannot be resolved to a variable.

当我删除I​​f Statement时,我没有收到任何错误:

<%
        String cssClassContainer = "container";
%>
Run Code Online (Sandbox Code Playgroud)

为什么?

任何帮助表示赞赏!非常感谢!

java jsp

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

我可以将 jQuery 与 Javascript 结合使用吗?

我想使用JavaScript选择document.querySelectorinsted的的$jQueryjQuery选择,但我想给Javascript选择使用jQuery函数(如合并.getJSON().html().append(),等)。

例如:

$.getJSON("list.json", function(data) {
    document.querySelector("#content").html(data.name);
});
Run Code Online (Sandbox Code Playgroud)

在这里,当我使用document.querySelector我得到的Uncaught TypeError: undefined is not a function,当我使用$我没有得到任何错误。

jsFiddle Test

是否可以同时运行 jQuery 和 Javascript?

谢谢!

javascript jquery

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

如何从MediaWiki的URL中删除index.php?

我使用此工具http://shorturls.redwerks.org/重写了MediaWiki的短网址。从这个:http://wikitest.org/fr/index.php/Accueil到这个:http://wikitest.org/fr/wiki/Accueil

Then I added this code to LocalSettings.php:
## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs please see:
## http://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/fr";
$wgScriptExtension = ".php";
$wgArticlePath = "{$wgScriptPath}/wiki/$1";
$wgUsePathInfo = true
Run Code Online (Sandbox Code Playgroud)

但是,当我转到自己的网站时,会看到404 Not Found。在此服务器上找不到请求的资源!

php mediawiki

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

如何将相应的表头(th)复制到其表格单元格(td)?

我想将<th> table的内容复制到<td>单元格的相应属性.

我的桌子是这样的:

<table>
    <thead>
        <tr>
            <th>Heading 1</th>
            <th>Heading 2</th>
            <th>Heading 3</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Lorem</td>
            <td>lipsum</td>
            <td>dolor</td>
        </tr>
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

这就是我要实现的目标:

<table>
    <thead>
        <tr>
            <th>Heading 1</th>
            <th>Heading 2</th>
            <th>Heading 3</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td data-attr="Heading 1">Lorem</td>
            <td data-attr="Heading 2">lipsum</td>
            <td data-attr="Heading 3">dolor</td>
        </tr>
    </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

我试过这个,但它不起作用:

var $th = $("thead td");
var $td = $("tbody td")

var $th = $td.closest('table').find('th').eq($td.index());
$td.attr("data-attr", $th);
Run Code Online (Sandbox Code Playgroud)

jsFiddle

在我的自定义属性中,我得到data-attr="[object Object]"了文本的内容.

javascript jquery

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

标签 统计

javascript ×5

jquery ×5

django ×2

python ×2

java ×1

jsp ×1

mediawiki ×1

php ×1

postgresql ×1