js for no_has_list
This commit is contained in:
parent
dcc59293ba
commit
9025c309b3
|
@ -124,7 +124,7 @@ class BestPracticeCategory(models.Model):
|
|||
'description': self.description
|
||||
}
|
||||
|
||||
class BestPracticeLink(models.Model):
|
||||
class BestPracticeLink(ItfModel):
|
||||
url = models.URLField()
|
||||
text = models.TextField(blank=True)
|
||||
bestpractice = models.ForeignKey(BestPractice)
|
||||
|
@ -135,6 +135,13 @@ class BestPracticeLink(models.Model):
|
|||
'text': self.text
|
||||
}
|
||||
|
||||
def list_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
'text': self.text,
|
||||
'url': self.url,
|
||||
}
|
||||
|
||||
def __unicode__(self):
|
||||
return self.url
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ class Participant(ItfModel):
|
|||
return self.name
|
||||
|
||||
def get_title(self):
|
||||
return self.title
|
||||
return self.name
|
||||
|
||||
def list_dict(self):
|
||||
return {
|
||||
|
|
|
@ -69,7 +69,7 @@ $(function() {
|
|||
// $('#loadingList').hide();
|
||||
stopListLoading(data.page);
|
||||
/* begin if for has_list, ideally make into separate render function */
|
||||
// if (data.has_list) {
|
||||
if (data.has_list) {
|
||||
/* handle sort options on list */
|
||||
$select = $('#orderBySelect');
|
||||
$select.empty();
|
||||
|
@ -86,10 +86,12 @@ $(function() {
|
|||
displayList(data.page.items);
|
||||
/* end display initial list */
|
||||
|
||||
// }
|
||||
} else {
|
||||
/* end if has_list */
|
||||
|
||||
|
||||
$('#textRight').text(data.title);
|
||||
var $html = getNoListHtml(data.page.items);
|
||||
$('#bottomRight').empty().append($html);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -170,3 +172,26 @@ function getPage(pageNo) {
|
|||
displayList(page.items);
|
||||
});
|
||||
}
|
||||
|
||||
function getNoListHtml(items) {
|
||||
var $rhs = $('<div />');
|
||||
for (var i=0; i<items.length; i++) {
|
||||
var $obj = getNoListItemHtml(items[i]);
|
||||
$rhs.append($obj);
|
||||
}
|
||||
return $rhs;
|
||||
}
|
||||
|
||||
function getNoListItemHtml(item) {
|
||||
if (item.hasOwnProperty("url")) {
|
||||
var $ret = $('<div />').addClass("noListItem");
|
||||
var $title = $("<div />").addClass("orange").appendTo($ret);
|
||||
var $a = $('<a />').attr("href", item.url).text(item.text).appendTo($title);
|
||||
var $text = $("<div />").addClass("noListText").html(item.text).appendTo($ret);
|
||||
} else {
|
||||
var $ret = $('<div />').addClass("noListItem").addClass("collapsible");
|
||||
var $title = $("<div />").addClass("orange").addClass("toggleNext").text(item.title).appendTo($ret);
|
||||
var $text = $("<div />").addClass("noListText").addClass("hidden").html(item.text).appendTo($ret);
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
|
||||
|
||||
<div class="linksInnerOrange">
|
||||
<a href="" class="orange">Dummy Link 1</a>
|
||||
<a href="#" class="orange toggleNext">Dummy Link 1</a>
|
||||
<div class="hideText">Dummy text that displays on clicking link</div>
|
||||
<a href="" class="orange">Dummy Link 2</a>
|
||||
<a href="#" class="orange toggleNext">Dummy Link 2</a>
|
||||
<div class="hideText">Dummy text that displays on clicking link</div>
|
||||
<a href="" class="orange">Dummy Link 3</a>
|
||||
<a href="#" class="orange toggleNext">Dummy Link 3</a>
|
||||
<div class="hideText">Dummy text that displays on clicking link</div>
|
||||
<a href="" class="orange">Dummy Link 4</a>
|
||||
<a href="#" class="orange toggleNext">Dummy Link 4</a>
|
||||
<div class="hideText">Dummy text that displays on clicking link</div>
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user