MVC4和JQuery Mobile - 有时某些ActionLink按钮在特定时间不起作用,直到我刷新页面或在新选项卡中打开

时间:2021-12-29 01:32:17

I'm trying to figure out why after I create a record in my app the same "Create New" button doesn't seem to work anymore until I either refresh the page, or I open the link in a new window.

我试图弄清楚为什么在我的应用程序中创建一个记录后,相同的“创建新”按钮似乎不再起作用,直到我刷新页面,或者我在新窗口中打开链接。

  1. I'll click "Create New" button at the top right: MVC4和JQuery Mobile  - 有时某些ActionLink按钮在特定时间不起作用,直到我刷新页面或在新选项卡中打开

    我将点击右上角的“新建”按钮:

  2. I'm taken to the Create view. Then I'll fill out the form and click Create: MVC4和JQuery Mobile  - 有时某些ActionLink按钮在特定时间不起作用,直到我刷新页面或在新选项卡中打开

    我被带到了创建视图。然后我将填写表单并单击Create:

  3. Notice the new record in my list now: MVC4和JQuery Mobile  - 有时某些ActionLink按钮在特定时间不起作用,直到我刷新页面或在新选项卡中打开

    现在注意我的列表中的新记录:

  4. But see how I click the same Create New button, it just stays highlighted blue (this is the color it turns when you click on it)? Nothing happens, but if I right click and open this link in a new tab, then the new tab will have the Create New form. I can also do a programatic page reload via JavaScript which will solve this problem, but I don't want to do that. Hovering over the link shows the correct route at the bottom the browser window, so I am not sure why this isn't working!! Please help!!! MVC4和JQuery Mobile  - 有时某些ActionLink按钮在特定时间不起作用,直到我刷新页面或在新选项卡中打开

    但是看看我如何单击相同的“创建新”按钮,它只是保持突出显示为蓝色(这是它点击它时转动的颜色)?没有任何反应,但如果我右键单击并在新选项卡中打开此链接,则新选项卡将具有“新建”表单。我也可以通过JavaScript重新加载程序页面来解决这个问题,但我不想这样做。将鼠标悬停在链接上会在浏览器窗口底部显示正确的路由,所以我不确定为什么这不起作用!!请帮忙!!!

1 个解决方案

#1


0  

I finally figured this one out on my own. In my situation, when I was in my Index view looking at the list of items, I then clicked "Create" to create a new item. Once I created it, it redirected me back to the Index view (as expected). It was at this point that I couldn't any longer click the Create New button (as described above).

我终于自己想出了这个。在我的情况下,当我在索引视图中查看项目列表时,我然后单击“创建”以创建新项目。一旦我创建了它,它就会将我重定向回Index视图(如预期的那样)。正是在这一点上,我再也无法单击“创建新”按钮(如上所述)。

So, here's my solution.

所以,这是我的解决方案。

In your Create view, specify in the BeginForm() call your Action and Controller, and add an Html Attribute called 'data_ajax = "false"'. That's all you need to do.

在Create视图中,在BeginForm()中指定调用Action和Controller,并添加一个名为'data_ajax =“false”'的Html属性。这就是你需要做的。

@using (Html.BeginForm("Create", "Fillers", FormMethod.Post, new { data_ajax = "false" }))
{
    @Html.ValidationSummary(true)

    @Html.Partial("_CreateOrEdit", Model)

    <p>
        <input type="submit" value="Create" data-ajax="false" />
    </p>
}

Now, when you create a new item and you get redirected back to the Index view, you are now able to click the Create New button again. Keep in mind though that by doing this you will lose the cool animated rotating GIF that says "hey, something's processing, hang on". I don't know of any other way around it at the moment.

现在,当您创建新项目并重定向回“索引”视图时,您现在可以再次单击“新建”按钮。请记住,通过这样做,你将失去酷炫的动画旋转GIF,上面写着“嘿,某事正在处理,坚持下去”。我现在还不知道其他任何方式。

#1


0  

I finally figured this one out on my own. In my situation, when I was in my Index view looking at the list of items, I then clicked "Create" to create a new item. Once I created it, it redirected me back to the Index view (as expected). It was at this point that I couldn't any longer click the Create New button (as described above).

我终于自己想出了这个。在我的情况下,当我在索引视图中查看项目列表时,我然后单击“创建”以创建新项目。一旦我创建了它,它就会将我重定向回Index视图(如预期的那样)。正是在这一点上,我再也无法单击“创建新”按钮(如上所述)。

So, here's my solution.

所以,这是我的解决方案。

In your Create view, specify in the BeginForm() call your Action and Controller, and add an Html Attribute called 'data_ajax = "false"'. That's all you need to do.

在Create视图中,在BeginForm()中指定调用Action和Controller,并添加一个名为'data_ajax =“false”'的Html属性。这就是你需要做的。

@using (Html.BeginForm("Create", "Fillers", FormMethod.Post, new { data_ajax = "false" }))
{
    @Html.ValidationSummary(true)

    @Html.Partial("_CreateOrEdit", Model)

    <p>
        <input type="submit" value="Create" data-ajax="false" />
    </p>
}

Now, when you create a new item and you get redirected back to the Index view, you are now able to click the Create New button again. Keep in mind though that by doing this you will lose the cool animated rotating GIF that says "hey, something's processing, hang on". I don't know of any other way around it at the moment.

现在,当您创建新项目并重定向回“索引”视图时,您现在可以再次单击“新建”按钮。请记住,通过这样做,你将失去酷炫的动画旋转GIF,上面写着“嘿,某事正在处理,坚持下去”。我现在还不知道其他任何方式。