0
我目前正在尝试使用jQuery处理无序列表,本质上我有一个无序列表中的链接列表,某些用户只能访问(所有设置服务器端)某些文件/页面。使用jQuery处理列表项目
我一直希望使用一些jQuery从DOM中删除一些列表项,只是因为它更吸引我没有用户点击链接,加载页面,然后显示错误,因为他们有访问不足。
我已经有一个对象设置,并成功地从DOM中删除了一个独立的链接,尽管我似乎无法让选择器正确地删除列表项。
列表HTML:
<div id="browse" class="bubble">
<blockquote>
<ul id="browses">
<li><a href="browse.php?id=15" class="browse">Access</a><br /></li> //trying to remove
<li><a href="browse.php?id=1" class="browse">Accounts</a><br /></li> //trying to remove
<li><a href="browse.php?id=2" class="browse">Browse's</a><br /></li> //trying to remove
<li><a href="browse.php?id=7" class="browse">Commands</a><br /></li> //trying to remove
<li><a href="browse.php?id=4" class="browse">Content</a><br /></li>
<li><a href="browse.php?id=8" class="browse">Logs</a><br /></li>
<li><a href="browse.php?id=10" class="browse">Sessions</a><br /></li>
<li><a href="browse.php?id=11" class="browse">Settings</a><br /></li> //trying to remove
<li><a href="browse.php?id=12" class="browse">Sites</a><br /></li> //trying to remove
</ul>
</blockquote>
<cite>Browse and manage the currently active sites data</cite>
</div>
对象迄今:
Session = function(){
this.init(phpdev_session);
}
$.extend(Session.prototype, {
// object variables
vars: '',
init: function(phpdev_session){
// do initialization here
this.vars = phpdev_session;
},
restrict: function() {
if (this.vars.account_class == '40') {
//access client or less, remove manage another site link and a few browses from #browse ul
//note: its all restricted server side, so its just a presentation layer.
$('a#activate').remove();
$('#browses').remove('li:eq(0)').remove('li:eq(1)').remove('li:eq(2)').remove('li:eq(3)').remove('li:eq(7)').remove('li:eq(8)');
}
}
});
$(document).ready(function() {
var session = new Session(phpdev_session);
session.restrict();
});
只是一个建议,但不显示一个安全的菜单项与显示它,但让它看起来“禁用”,通常可能是一个非直观的UI设计。 “看到”你无法访问的内容往往更容易,然后相反(你的设计意味着什么)。 :) – deadbug 2009-01-04 08:27:53
typo darnit:你应该是你的:) – deadbug 2009-01-04 08:28:53