html脚本标记内的javascript未运行

时间:2014-05-02 18:32:23

标签: javascript jquery html asp.net-mvc-4

简单但我似乎无法找到正确的谷歌单词来回答我的问题

我有以下cshtml文件

@using BAT.ViewModels
@model DocPortfolio

@{
    ViewBag.Title = "Describe Your Project";
}

<h2>Provide a Description of Your Project</h2>


@using (Html.BeginForm("GetDocumentPortfolio", "DocPortfolio"))
{
    <fieldset>
        <legend>
            Description of project sizes?
        </legend>

        @Html.DropDownListFor(x => Model.SelectedProjectSize, Model.ProjectSizes)

    </fieldset>

    <fieldset>
        <legend>
            What is the main form of communication for your team?
        </legend>
        <label class="radio">
            @Html.RadioButtonFor(model => model.CommunicationType, true, new { id =  "Verbal" }) 
            @Html.Label("Verbal", "Verbal")

        @Html.RadioButtonFor(model => model.CommunicationType, false, new { id = "Written" }) 
            @Html.Label("Written", "Written")

        </label>
    </fieldset>

    <div>
        <button type="submit" class="btn btn-primary btn-large">Generate Documents</button>
    </div>
}
<script language="text/javascript" >
$(function () {
    $('input, select, button').change(function () {
        window._eqatecmonitor.trackFeature("PortfolioFormItem." + $(this).attr("id"));
        alert("PortfolioFormItem." + $(this).attr("id"));
    });

    $('input').change(function () {
        window._eqatecmonitor.trackFeatureValue("PortfolioFormValue" + $(this).attr("name") + "." + $(this).val());
        alert("PortfolioFormValue" + $(this).attr("name") + "." + $(this).val());
    });

    $('select').change(function () {
        window._eqatecmonitor.trackFeatureValue("PortfolioFormValue" + $(this).attr("id") + "." + $(this).text());
        alert("PortfolioFormValue" + $(this).attr("id") + "." + $(this).text());
    });
});

如果我将代码复制并粘贴到脚本标记内,我的jquery按预期工作,但在页面加载时它不起作用。

我尝试过使用

$(document).ready(function(){ ... });

但这也不起作用。有人能指出我疲惫的眼睛朝着正确的方向吗?

0 个答案:

没有答案