0
I have an element in my Layout and I’m trying to set href via jquery, but it won’t. The condition is in my index. Follows the code:
Layout
<div class="three wide column dindex">
<div class="ui left fixed vertical blue inverted menu dmenu">
<div class="ui containe">
<h3 class="item">Menu Principal</h3>
</div>
<div class="ui container firstmenu">
<a id="itemsMD" class="item dalink menus" href="~/EAD/EDisciplinas/Conteudo">Material Didático</a>
<!--<a id="items" class="item" title="curso" href="#curso">Notas</a>-->
<a id="itemsA" class="item dalink menus">Avisos</a>
</div>
<div class="ui container secondmenu">
<a id="itemsP" class="item dalink" href="~/EAD/EPrincipal">Disciplinas</a>
<a id="itemsS" class="item dalink" href="~/EAD/EAccount/Sair">Sair</a>
</div>
</div>
</div>
Index - Jquery code
<script type="text/javascript">
$(function()
{
/* Atribui ID */
$("#itemsA").attr("href", "@ViewBag.IDDisciplina");
/* CRIA A HREF */
$('<a>', {
class: 'item dalink',
href: '~/EAD/EDisciplinas/Forum/@ViewBag.IDDisciplina',
text: 'Forum de Discussão'
}).appendTo('.firstmenu');
});
He creates the a href but stays the way it is: http://localhost:32322/EAD/Edisciplinas/Index/~/EAD/Edisciplinas/Forum/1
But I’d like you to stay http://localhost:32322/EAD/Edisciplinas/Forum/1
Can someone help me? I am programming in C# Asp.net MVC 5
Try this . /EAD/Edisciplinas/Forum/@Viewbag.Iddisciplina',
– PauloHDSousa
Continue creating the link: http://localhost:32322/EAD/Edisciplinas/Index/EAD/Edisciplinas/Forum/1
– Deivid Farias
AND WITHOUT THE POINT? /EAD/Edisciplinas/Forum/@Viewbag.Iddisciplina
– PauloHDSousa
If the point was friend. Thank you. Put as reply please,so I can mark. Thank you even
– Deivid Farias