小编Gab*_*Gab的帖子

带有fadeIn效果的jQuery .load()

我正试图在#primary中使用jQuery通过AJAX加载URL的#content.它加载但不会淡入.我究竟做错了什么?

$('.menu a').live('click', function(event) {
        var link = $(this).attr('href');
        $('#content').fadeOut('slow', function(){
            $('#primary').load(link+' #content', function(){
                $('#content').fadeIn('slow');
            });
        });
        return false;
    });
Run Code Online (Sandbox Code Playgroud)

非常感谢您的帮助.

jquery load fadein

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

Window.location.hash需要语法帮助

我的网站位于http://visualise.ca/,当您点击缩略图加载帖子时,它将使用ajax加载页面中的帖子.关闭帖子时,它使用此代码,以便在不重新加载页面的情况下将网址更改回http://visualise.ca/:

$("#close").live("click", function(event) {
    $("#board").fadeOut("slow");
    $("#board-wrapper").slideUp("slow");
    $("html,body").delay(1000).animate({scrollTop: 0}, 300);
    window.location.hash = "";
    window.history.pushState(null,null,site_url+"/");
    return false;
});
Run Code Online (Sandbox Code Playgroud)

但在IE8中,它将其更改为http://visualise.ca/#而不是http://visualise.ca/.有没有办法纠正这个并确保它改为http://visualise.ca/

hash jquery window.location

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

jquery隐藏标记中的文本内容,而不是标记本身

我有一个使用此html语法的滑块:

<div id="theatre">
    <a class="sliderImg" href="01.jpg" />some-text</a>
    <a class="sliderImg" href="02.jpg" />another-description</a>
    <a class="sliderImg" href="03.jpg" />whatever</a>
    <a class="sliderImg" href="04.jpg" />whatever</a>
</div>
Run Code Online (Sandbox Code Playgroud)

我需要做的是隐藏标签的文本而不是标签本身.

我得到了这个但是没有用.

var imgCaptions = $("#theatre a.sliderImg").html();
$(imgCaptions).hide();
Run Code Online (Sandbox Code Playgroud)

我无法添加跨度,因为我将内容用于某些AJAX.结构必须保留.

非常感谢您的帮助.圣诞快乐!

html jquery hide

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

使用.split()将字符串转换为数组(需要改进)

我正在尝试使用JavaScript来转换此字符串

.txt|.pdf|.xls|.xlsx|.doc|.docx|.rtf|.jpg|.jpeg|.png|.gif

进入这个数组

["txt", "pdf", "xls", "xlsx", "doc", "docx", "rtf", "jpg", "jpeg", "png", "gif"]

但它给了我这个

[".txt", "pdf", "xls", "xlsx", "doc", "docx", "rtf", "jpg", "jpeg", "png", "gif"]

它将点保持在第一个元素的前面.因为我不知道正则表达式,我能做什么?这是我的代码:

let fileTypes = string.split('|.');
Run Code Online (Sandbox Code Playgroud)

javascript regex arrays string

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

React Router将IndexRoute重定向到正确的路径

我正在尝试配置React Router,以便在访问http:// url/manage/roomId时直接转到http:// url/manage/roomId/sessions(加载RoomSessions组件).这些是标签组件的路由,我想默认使用正确的URL(它没有)加载第一个标签的内容(它所做的).

除重定向外,它工作正常

                    <Route path='manage/:roomId' component={RoomsManagerManageRoom} onEnter={requireAuth}>
                        <IndexRoute component={RoomSessions} onEnter={requireAuth} />
                        <Route path='sessions' component={RoomSessions} onEnter={requireAuth} />
                        <Route path='meetings' component={RoomMeetings} onEnter={requireAuth} />
                        <Route path='files' component={RoomFiles} onEnter={requireAuth} />
                        <Route path='recordings' component={RoomRecordings} onEnter={requireAuth} />
                        <Route path='sections' component={RoomSections} onEnter={requireAuth} />
                        <Route path='hosts' component={RoomHosts} onEnter={requireAuth} />
                    </Route>
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

jsx reactjs react-jsx react-router

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

运行 tsc(TypeScript 编译器)时如何将 package.json 复制到 dist 或 build 文件夹中

我有一个使用package.json文件的 TypeScript React 组件(参见屏幕截图),我运行tsc以将其转换为dist文件夹中的es5,但该package.json文件没有被复制。请注意,在屏幕截图中,我手动将其复制到dist文件夹中。

组件截图

所以我的问题是:有没有办法通过tsc/tsconfig...来做到这一点,而不必添加复制脚本(通过 运行yarn build)。因为我希望在运行时也能更新tsc --watch

此外,我不希望在组件文件夹中将我的 Component.tsx 重命名为 index.tsx。我不想在我的项目中有 200 个 index.tsx 文件并且使用package.json'smain允许我拥有import SomeComponent from './components/SomeComponent'而不是这样做import SomeComponent from './components/SomeComponent/SomeComponent'很好。

这是我的tsconfig文件:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "skipLibCheck": true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "commonjs",
    "outDir": "dist",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization": false,
    "declaration": …
Run Code Online (Sandbox Code Playgroud)

npm typescript tsc reactjs package.json

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

scrollTo同位素插件

我的投资组合位于http://www.visualise.ca/,我正在研究运行同位素的新版本.它可以在http://themes.visualise.ca/visualise上找到.

当我点击将在页面中加载帖子的图像缩略图时,我希望页面使用jQuery scrollTo插件和以下代码滚动到项目(单击的图像缩略图):

$container.delegate( $itemString, 'click', function(){
        $(this).toggleClass('large');
        $container.isotope('reLayout');
        $('html,body').scrollTo(this, 800);
});
Run Code Online (Sandbox Code Playgroud)

但经过测试,看起来物品的位置总是顶部:1左:容器的1(如果物品没有1px边框,则为0).此外,当我使用Firebug检查项目时,突出显示的蓝线不在项目本身上,而是位于顶部:1左侧:容器中的1.

所以我怀疑因为同位素所有的插件现在都认为所有项目都位于0,0(1,1因为我的情况下的边距).

为了正确滚动,我该怎么办?

非常感谢您的时间和帮助.

scrollto jquery-isotope

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

Wordpress和jQuery - 导入<?php bloginfo('url'); ?>脚本文件

我正在使用Wordpress,我想将<?php bloginfo('url'); ?>jQuery脚本文件中的值用作变量.那可能吗?如何?

在我的script.js文件中,我使用了一个函数:

$("#board").load("http://www.mysite.com/ajax/",{slug:post_slug});
Run Code Online (Sandbox Code Playgroud)

而"http://www.mysite.com"部分将改变(我正在构建一个主题).

非常感谢您的时间和帮助.

wordpress jquery

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