小编Tui*_*izi的帖子

jQuery:停止提交表单,执行脚本,继续提交表单?

我有一个表单,当我提交他时,我执行多个脚本.这是我的代码:

$("#RequestCreateForm").submit(function (e) {
    if ($("#RequestCreateForm").validate().checkForm() == false) { return; }

    e.preventDefault();

    //many scripts

    //How to continue submitting?
}
Run Code Online (Sandbox Code Playgroud)

之后是否可以继续提交表格(停止时e.preventDefault();)//many scripts

谢谢

javascript jquery jquery-selectors

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

Eval()=意外的令牌:错误

我尝试了这个简单的JavaScript代码:

eval('{"Topics":["toto","tata","titi"]}')
Run Code Online (Sandbox Code Playgroud)

例如,在Chrome控制台中,会返回

SyntaxError:意外的令牌:

我在JSONLint上尝试了JSON ,它是有效的.

你看到了这个bug吗?

javascript json eval

17
推荐指数
4
解决办法
3万
查看次数

MVC2:无法用TextBoxFor更改名称?

我想手动为文本框定义id和名称:

<%: Html.TextBoxFor(model => model.Name, new { @id = "txt1", @name = "txt1" })%>
Run Code Online (Sandbox Code Playgroud)

但只有id被更改,而不是name属性,为什么?

<input id="txt1" name="Name" type="text" value="">
Run Code Online (Sandbox Code Playgroud)

谢谢!

html asp.net asp.net-mvc asp.net-mvc-2 html.textboxfor

6
推荐指数
3
解决办法
6486
查看次数

相当于 Typescript 声明文件中的 module.exports

我尝试做一个库的声明文件。

library.js文件中,有:

if (typeof module !== 'undefined' /* && !!module.exports*/) {
    module.exports = Library;
}
Run Code Online (Sandbox Code Playgroud)

我应该在我的library.d.ts文件中放入什么才能在我的代码中导入和使用这个库?

我希望能够做到:

import { Library } from 'library';
const instance = new Library();
Run Code Online (Sandbox Code Playgroud)

typescript

6
推荐指数
2
解决办法
7818
查看次数

jQuery验证:未调用自定义规则

这是我用于测试的简单验证代码:

    jQuery.validator.addMethod("oneTypeChecked", function (value, element) {
        return false; //$(':checkbox:checked') > 0
    }, "Check one or more type");

    $("#RequestCreateForm").validate({
        rules: {
            ChkBoxType1: { oneTypeChecked: true }
        }
    });
Run Code Online (Sandbox Code Playgroud)

但是当我提交表单时,我的方法oneTypeChecked永远不会被调用.为什么?

这是我的HTML代码:

<div class="editor-field">
    <input type="checkbox" id="ChkBoxType2" name="requestTypeIds2" value="2">Type 2     
    <input type="checkbox" id="ChkBoxType1" name="requestTypeIds1" value="1">Type 1        
    <input type="checkbox" id="ChkBoxType3" name="requestTypeIds3" value="3">Type 3
</div>
Run Code Online (Sandbox Code Playgroud)

非常感谢你!

jquery jquery-validate

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

为什么我无法解析 css 文件的客户端 url?

这是我的asp代码:

<!-- language: lang-js -->
<head runat="server">
    <title>
        <asp:ContentPlaceHolder ID="TitleContent" runat="server" />
    </title>
    <link href='<%: ResolveClientUrl("~/Content/Site.css") %>' rel="stylesheet" type="text/css" />
    <script src='<%: ResolveClientUrl("~/Scripts/jquery.js")%>' type="text/javascript" />
    <script src='<%: ResolveClientUrl("~/Scripts/jquery-ui.js")%>' type="text/javascript" />
    <link href='<%: ResolveClientUrl("~/Content/redmond/jquery-ui.css") %>' rel="stylesheet" type="text/css" class="ui-theme" />
</head>
Run Code Online (Sandbox Code Playgroud)

这是呈现的html:

<!-- language: lang-js -->
<head>
    <title>Espace de travail</title>
    <link href="&lt;%: ResolveClientUrl(&quot;~/Content/Site.css&quot;) %>" rel="stylesheet" type="text/css" />
    <script src='Scripts/jquery.js' type="text/javascript"></script>
    <script src='Scripts/jquery-ui.js' type="text/javascript"></script>
    <link href="&lt;%: ResolveClientUrl(&quot;~/Content/redmond/jquery-ui.css&quot;) %>" rel="stylesheet" type="text/css" class="ui-theme" />
</head>
Run Code Online (Sandbox Code Playgroud)

为什么 asp 可以为我的 .js 脚本文件解析 url 而不能为我的 css 文件解析?

asp.net asp.net-mvc asp.net-mvc-3 asp.net-mvc-2

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