Skip to main content
added 22 characters in body
Source Link
Legato
  • 9.8k
  • 4
  • 49
  • 116

It's more of a personal preference thing, but I would recommend removing the onclicks in the following:

<li onclick="showApps()"><a href="#" class="ui-btn-active">Apps</a></li>
<li onclick="showServers()"><a href="#">Servers</a></li>
<li onclick="showVariableGroups()"><a href="#">Variables</a></li>

Instead, my recommendation would be to put a class on the links, say something like this:

<li><a href="#" class="navLink">Apps</a></li>
<li><a href="#" class="navLink">Servers</a></li>

Then in jquery, add something like the following:

$(".navLink").click(function (e) {
  var link = $(this);
  switch (link.text()) {
     case "Apps":
       $("#appList").fadeIn(500);
       break;
     case "Servers":
       $("#serverList").fadeIn(500);
       break;
  }
});

Also, for the partialviews, you cannot render javascript in those (that I've found), so the easiest way to ensure that you can jQuery those would be to add a

$(document).delegate(".appListItem", "click", function (e) {
   // Stuff to do when clicking an item in the appList.
});

Also, if you would prefer to not have to load all the partialviews on page load (something I've found can slow down a page's loadtime), you might try something along the lines of changing your navlinks to something like this:

<li><a href="@Url.Action("GetMyApps", "Apps")" class="topLevelNavLink">Apps</a></li>

And then in jQuery do this:

$(".topLevelNavLink").click(function (e) { var url = $(this).attr("href"); $("#contentDiv").load(url); });

$(".topLevelNavLink").click(function (e) {
      var url = $(this).attr("href");
      $("#contentDiv").load(url);
   });

There are many different ways to do it, and it really is a matter of preference. Your way doesn't look bad, but it would drive my OCD through the roof with the onclicks in the html tags and the loading of the divs that are hidden when loading the page (I'm a firm believer in passing only as much data across the wire as is necessary to display what is expected - to improve performance (even if it's just a few milliseconds) and lower the bandwidth used). But again it's all a matter of preference.

It's more of a personal preference thing, but I would recommend removing the onclicks in the following:

<li onclick="showApps()"><a href="#" class="ui-btn-active">Apps</a></li>
<li onclick="showServers()"><a href="#">Servers</a></li>
<li onclick="showVariableGroups()"><a href="#">Variables</a></li>

Instead, my recommendation would be to put a class on the links, say something like this:

<li><a href="#" class="navLink">Apps</a></li>
<li><a href="#" class="navLink">Servers</a></li>

Then in jquery, add something like the following:

$(".navLink").click(function (e) {
  var link = $(this);
  switch (link.text()) {
     case "Apps":
       $("#appList").fadeIn(500);
       break;
     case "Servers":
       $("#serverList").fadeIn(500);
       break;
  }
});

Also, for the partialviews, you cannot render javascript in those (that I've found), so the easiest way to ensure that you can jQuery those would be to add a

$(document).delegate(".appListItem", "click", function (e) {
   // Stuff to do when clicking an item in the appList.
});

Also, if you would prefer to not have to load all the partialviews on page load (something I've found can slow down a page's loadtime), you might try something along the lines of changing your navlinks to something like this:

<li><a href="@Url.Action("GetMyApps", "Apps")" class="topLevelNavLink">Apps</a></li>

And then in jQuery do this:

$(".topLevelNavLink").click(function (e) { var url = $(this).attr("href"); $("#contentDiv").load(url); });

There are many different ways to do it, and it really is a matter of preference. Your way doesn't look bad, but it would drive my OCD through the roof with the onclicks in the html tags and the loading of the divs that are hidden when loading the page (I'm a firm believer in passing only as much data across the wire as is necessary to display what is expected - to improve performance (even if it's just a few milliseconds) and lower the bandwidth used). But again it's all a matter of preference.

It's more of a personal preference thing, but I would recommend removing the onclicks in the following:

<li onclick="showApps()"><a href="#" class="ui-btn-active">Apps</a></li>
<li onclick="showServers()"><a href="#">Servers</a></li>
<li onclick="showVariableGroups()"><a href="#">Variables</a></li>

Instead, my recommendation would be to put a class on the links, say something like this:

<li><a href="#" class="navLink">Apps</a></li>
<li><a href="#" class="navLink">Servers</a></li>

Then in jquery, add something like the following:

$(".navLink").click(function (e) {
  var link = $(this);
  switch (link.text()) {
     case "Apps":
       $("#appList").fadeIn(500);
       break;
     case "Servers":
       $("#serverList").fadeIn(500);
       break;
  }
});

Also, for the partialviews, you cannot render javascript in those (that I've found), so the easiest way to ensure that you can jQuery those would be to add a

$(document).delegate(".appListItem", "click", function (e) {
   // Stuff to do when clicking an item in the appList.
});

Also, if you would prefer to not have to load all the partialviews on page load (something I've found can slow down a page's loadtime), you might try something along the lines of changing your navlinks to something like this:

<li><a href="@Url.Action("GetMyApps", "Apps")" class="topLevelNavLink">Apps</a></li>

And then in jQuery do this:

$(".topLevelNavLink").click(function (e) {
      var url = $(this).attr("href");
      $("#contentDiv").load(url);
   });

There are many different ways to do it, and it really is a matter of preference. Your way doesn't look bad, but it would drive my OCD through the roof with the onclicks in the html tags and the loading of the divs that are hidden when loading the page (I'm a firm believer in passing only as much data across the wire as is necessary to display what is expected - to improve performance (even if it's just a few milliseconds) and lower the bandwidth used). But again it's all a matter of preference.

Source Link
Bardicer
  • 186
  • 2
  • 11

It's more of a personal preference thing, but I would recommend removing the onclicks in the following:

<li onclick="showApps()"><a href="#" class="ui-btn-active">Apps</a></li>
<li onclick="showServers()"><a href="#">Servers</a></li>
<li onclick="showVariableGroups()"><a href="#">Variables</a></li>

Instead, my recommendation would be to put a class on the links, say something like this:

<li><a href="#" class="navLink">Apps</a></li>
<li><a href="#" class="navLink">Servers</a></li>

Then in jquery, add something like the following:

$(".navLink").click(function (e) {
  var link = $(this);
  switch (link.text()) {
     case "Apps":
       $("#appList").fadeIn(500);
       break;
     case "Servers":
       $("#serverList").fadeIn(500);
       break;
  }
});

Also, for the partialviews, you cannot render javascript in those (that I've found), so the easiest way to ensure that you can jQuery those would be to add a

$(document).delegate(".appListItem", "click", function (e) {
   // Stuff to do when clicking an item in the appList.
});

Also, if you would prefer to not have to load all the partialviews on page load (something I've found can slow down a page's loadtime), you might try something along the lines of changing your navlinks to something like this:

<li><a href="@Url.Action("GetMyApps", "Apps")" class="topLevelNavLink">Apps</a></li>

And then in jQuery do this:

$(".topLevelNavLink").click(function (e) { var url = $(this).attr("href"); $("#contentDiv").load(url); });

There are many different ways to do it, and it really is a matter of preference. Your way doesn't look bad, but it would drive my OCD through the roof with the onclicks in the html tags and the loading of the divs that are hidden when loading the page (I'm a firm believer in passing only as much data across the wire as is necessary to display what is expected - to improve performance (even if it's just a few milliseconds) and lower the bandwidth used). But again it's all a matter of preference.