I have a view in which I want links to be enabled/disabled depending
on the user being logged in and his account settings.
{{if not auth.is_logged_in():}}
<script type="text/javascript">
$(document).ready(function(){
$('#root a').click(function(e) {e.preventDefault();});
$('#hub a').click(function(e) {e.preventDefault();});
$('#vcardsite a').click(function(e) {e.preventDefault();});
$('#calendar a').click(function(e) {e.preventDefault();});
});
</script>
<style type="text/css">
.admin {opacity: 0.5; filter:Alpha(opacity=50);}
</style>
{{else:}}
<script type="text/javascript">
$(document).ready(function(){
$('#root a').click(function(e) {e.preventDefault();});
$('#hub a').click(function(e) {e.preventDefault();});
$('#vcardsite a').click(function(e) {e.preventDefault();});
$('#calendar a').click(function(e) {e.preventDefault();});
});
{{if rows:}}
{{for row in rows:}}
{{i=row.accountID}}
{{if i==1:}}
$('#root a').unbind('click',function(e));
{{elif i==2:}}
$('#hub a').unbind('click',function(e));
{{elif i==3:}}
$('#vcardsite a').unbind('click',function(e));
{{elif i==4:}}
$('#calendar a').unbind('click',function(e));
{{pass}}
{{pass}}
{{pass}}
</script>
<style type="text/css">
#root, #hub, #vcardsite, #calendar {opacity: 0.5;
filter:Alpha(opacity=50);}
{{if rows:}}
{{for row in rows:}}
{{i=row.accountID}}
{{if i==1:}}
#root {opacity: 1.0; filter:Alpha(opacity=100);}
{{elif i==2:}}
#hub {opacity: 1.0; filter:Alpha(opacity=100);}
{{elif i==3:}}
#vcardsite {opacity: 1.0; filter:Alpha(opacity=100);}
{{elif i==4:}}
#calendar {opacity: 1.0; filter:Alpha(opacity=100);}
{{pass}}
{{pass}}
{{pass}}
</style>
{{pass}}
The css part works, the {{if not auth.is_logged_in():}} javascript
part works, however, the {{else:}}
<script type="text/javascript"> {{if rows:}} ... {{pass}} </script>
{{pass}} part doesn't work. This:
{{if rows:}}
{{for row in rows:}}
{{i=row.accountID}}
{{if i==1:}}
$('#root a').unbind('click',function(e));
{{elif i==2:}}
$('#hub a').unbind('click',function(e));
{{elif i==3:}}
$('#vcardsite a').unbind('click',function(e));
{{elif i==4:}}
$('#calendar a').unbind('click',function(e));
{{pass}}
{{pass}}
{{pass}}
... gives all the links their default behaviour back. If accountID=2
not only the #hub link becomes clickable the # root, #vcardsite and
#calendar links become clickable as well. How do I code the desired
behaviour correctly?
Kind regards,
Annet.