From 4e4333f4e2d04db06888c1613f8600da9b669de4 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Mon, 13 Apr 2015 18:15:06 -0300 Subject: [PATCH] accessing noosfero API --- index.html | 20 ++++++++++++++++---- js/main.js | 29 +++++++++++++++-------------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/index.html b/index.html index 11b6f38..e93b17c 100644 --- a/index.html +++ b/index.html @@ -1,16 +1,28 @@ + +
diff --git a/js/main.js b/js/main.js index 006b751..b0f8ac5 100644 --- a/js/main.js +++ b/js/main.js @@ -7,20 +7,21 @@ var template = Handlebars.compile(templateSource); // The div/container that we are going to display the results in var resultsPlaceholder = document.getElementById('proposal-result'); +var topics; -$.ajax({ - dataType: "json", - url: 'http://localhost:3000/api/v1/articles?private_token=89419a2d331a17e815c3ecc53b303aac&content_type=ProposalsDiscussionPlugin::Topic&parent_id=377', - data: data, - success: success -}); +var noosferoAPI = 'http://localhost:3000/api/v1/articles?private_token=89419a2d331a17e815c3ecc53b303aac&content_type=ProposalsDiscussionPlugin::Topic&parent_id=377&callback=?'; -var data = { - "proposal": - { - "title": "Handlebars", - "description": "Demo" - } -}; +$.getJSON(noosferoAPI) + .done(function( data ) { + //console.log(data); + resultsPlaceholder.innerHTML = template(data); + $( 'a' ).click(function(){ + resultsPlaceholder.innerHTML = $('#proposal-' + this.id.replace('#','')).html(); + }); + //console.log(resultsPlaceholder); + }) + .fail(function( jqxhr, textStatus, error ) { + var err = textStatus + ", " + error; + console.log( "Request Failed: " + err ); + }); -resultsPlaceholder.innerHTML = template(data); -- libgit2 0.21.2