简体   繁体   中英

How to change link without reload (MVC2 / AJAX problem)

I have been following this example http://demos.telerik.com/aspnet-mvc/grid/selectionclientside?theme=webblue , and have finished it for my spec. In my spec, the top table lists the name of a number of different database tables, and then the bottom displays the data of whichever specific table name was clicked.

Now I have encountered a problem. Basically for the bottom table (in that example the orders table) I have added another column with an edit link for each row. Now obviously I will need to update where the link is pointing at. How can I do this? (I am unsure as I'm fairly sure this is using AJAX binding, but is more or less implemented for me)

For example, lets say (in the top table) I have links to seperate tables Country and State. They are similar Country (CountryId, CountryName) and State (StateId, StateName).

So the edit links should change like after clicking (for example)

State: http://localhost:xxxx/Tables/State/Edit/X

and after clicking

Country: http://localhost:xxxx/Tables/Country/Edit/X

Add javascript to the onclick event of the link/button. In this javascript, you can walk the DOM to find the html link element and change the href property of it.

http://www.w3schools.com/jsref/dom_obj_anchor.asp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM