2013-10-01 4 views
0

나는 asp.net mvc4 응용 프로그램을 가지고 있는데, 여기서는 treeview를 추가하려고합니다. result레이블을 jquery 라이브러리의 링크로 변경

이 좋다하지만 난 이런 링크에 각각의 제목을 변경해야합니다 : @Html.ActionLink("Projet", "Modify_Project")

결과이 같은 뷰가 graphdracula

<html> 
    <head> 
    <!-- jQuery --> 
    <script type="text/javascript" src="~/Content/Scripts/jquery-1.4.2.min.js"></script> 
    <!-- The Raphael JavaScript library for vector graphics display --> 
    <script type="text/javascript" src="~/Content/Scripts/raphael-min.js"></script> 
    <!-- Dracula --> 
    <!-- An extension of Raphael for connecting shapes --> 
    <script type="text/javascript" src="~/Content/Scripts/dracula_graffle.js"></script> 
    <!-- Graphs --> 
    <script type="text/javascript" src="~/Content/Scripts/dracula_graph.js"></script> 
    <script type="text/javascript" src="~/Content/Scripts/dracula_algorithms.js"></script> 
    <script type="text/javascript"> 
     //Show UCLA CS class dependencies (not complete) 
     $(document).ready(function() { 
      var width = $(document).width() -500; 
      var height = $(document).height(); 
      var g = new Graph(); 
      g.edgeFactory.template.style.directed = true; 
      g.addEdge("Projet", "Fonction1"); 
      g.addEdge("Fonction1", "Sous Fonction 1.1"); 
      g.addEdge("Fonction1", "Sous Fonction 1.2"); 
      g.addEdge("Projet", "Fonction2"); 
      g.addEdge("Fonction2", "Sous Fonction 2.1"); 
      g.addEdge("Fonction2", "Sous Fonction 2.2"); 
      g.addEdge("Fonction2", "Sous Fonction 2.3"); 
      g.addEdge("Fonction2", "Sous Fonction 2.4"); 
      var layouter = new Graph.Layout.Ordered(g, topological_sort(g)); 
      var renderer = new Graph.Renderer.Raphael('canvas', g, width, height); 
     }); 

    </script> 
    </head> 
    <body> 
    <div id="canvas"></div> 
</body> 
</html> 

입니다 : 그래서 나는이 jQuery 라이브러리를 사용 이 스 니펫을 수정하여이 작업을 수행하려면 어떻게해야합니까?

답변

1

jQuery를 사용하는 경우. 여기

// on page load 
$(function(){ 

// You need to identify a selector that selects all the titles you want to change.. 
// Likely they all have a certain class 
$('.titleSelector').changeElementType("a"); 

// Now you probably want to add an href 
$('a.titleSelector').attr('href','http://youlinkhere'); 

}); 

JQuery와로드 후 스크립트 전에 포함은 https://stackoverflow.com/a/8584217/602379

(function($) { 
    $.fn.changeElementType = function(newType) { 
     var attrs = {}; 

     $.each(this[0].attributes, function(idx, attr) { 
      attrs[attr.nodeName] = attr.nodeValue; 
     }); 

     this.replaceWith(function() { 
      return $("<" + newType + "/>", attrs).append($(this).contents()); 
     }); 
    }; 
})(jQuery); 
를 실행합니다 .. 플러그인입니다
관련 문제