开发者

Asp.Net MVC - dynamically altering ActionLink via jQuery

I have used jQuery to display info for a开发者_运维百科 record depending on some user selections. I need to add a button or a link that will take them to an Edit view, but don't know the best way to achieve this. The ID for the navigation will change as they browse the data.

Can I dynamically alter the ActionLink using jQuery?

More info Users make a selection from list boxes, then I go and get the appropriate data via a $.getJSON call. Information is then displayed in a summary box with the option to edit the data. So the fetch looks like this

$.getJSON("/Result/FetchState", { metricId: metId, calendarId: calId }, function (data) {
              $('#Info1').val(data.ResultId);
              $('#Info3').val(data.Headline);
              if (data.AllowEdit) { $('#btnEdit').attr('disabled', false); } else { $('#btnEdit').attr('disabled', true); }
              $('#editlink').val(data.ResultId);
          });

I now need to be able to navigate to a View (/Result/Edit/{id}) where {id} is the ResultId from the FetchState call.


You could use a <form> containing a hidden field and a submit button. When the user performs some selection you would set the value of the hidden field to this new selection:

$('#SomeHiddenField').val('some new value');

Then when the user submits the button this will redirect to the new action passing along the value of the hidden field.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜