dashboard: fixed javascript error if no slice
[myslice.git] / portal / templates / onelab / onelab_home-view.html
index f3090b2..090f66b 100644 (file)
                {% if person %}
         $.post("/rest/user/",{'filters':{'user_hrn':'$user_hrn'}}, function( data ) {
                  var items = [];
-                 $.each( data[0].slices, function(i, val) {
-                       items.push( "<li><a href=\"/slice/"+val+"\">" + val + "</a></li>" );
-                 });
-                 
-                 $("div#home-slice-list").html($( "<ul/>", { html: items.join( "" ) }));
-                 
+          if(data.length > 0){
+                   $.each( data[0].slices, function(i, val) {
+                           items.push( "<li><a href=\"/slice/"+val+"\">" + val + "</a></li>" );
+                   });
+                   $("div#home-slice-list").html($( "<ul/>", { html: items.join( "" ) }));
+                 }else{
+                   $("div#home-slice-list").html("no slice");
+          }
                });
                {% endif %}
        });