Reputation: 5564
I'm dynamically constructing URLs to pass to a jQuery button click event handler.
The URL comes from a modal window definition:
<div class="modal hide fade in" id="modal-view-tenant-profile"
data-url="Tenants/ViewProfile">...</div>
The id comes from a button:
<button class="btn btn-primary btn-block show-modal"
data-id="@result.UserId">View profile</button>
In my JS function I grab both pieces of data
var url = "Tenants/ViewProfile";
var id = $(this).attr('data-id');
and construct the URL like this $.get(url + '/' + id, function (data))...
To work, the URL should look like this:
http://localhost:1840/Tenants/ViewProfile/2
but because this controller action is invoked from a logged in Lanlord the URL looks like this:
http://localhost:1840/Landlords/Tenants/ViewProfile/2
I understand that I need to create a new route to ignore the 'Landlord' part of the URL, how do I do this when a landlord is invoking an action from the tenant contoller?
Upvotes: 0
Views: 351