0

I'm using the Tin Can API to present results from our LRS.

From the sample statement viewer I took:

$(document).ready(function(){
  TC_VIEWER = new TINCAN.Viewer();
  TC_VIEWER.pageInitialize();
  TC_VIEWER.searchStatements();
});

All works fine but the default presentation, particularly for date, is plain. Thought the easiest way to clean up the presentation was via a callback function on searchStatements:

$(document).ready(function(){
  TC_VIEWER = new TINCAN.Viewer();
  TC_VIEWER.pageInitialize();
  TC_VIEWER.searchStatements(function(){
    $(".date").css("color", "pink");  //test call only
  });
});

But the function never appears to get called?

  • what is the source of the searchStatements() function? What kind of parameters does it accept? – periklis Apr 16 '13 at 04:51
  • Taken from TinCanViewer.js, which is part of the TinCan JS API offered by Rustici: http://tincanapi.com/prototypes-getting-started/ – user2284913 Apr 16 '13 at 05:00

1 Answers1

0

The function searchStatements() doesn't accept any arguments, so what you've written won't work. Try running your code below the searchStatements() call:

$(document).ready(function(){
  TC_VIEWER = new TINCAN.Viewer();
  TC_VIEWER.pageInitialize();
  TC_VIEWER.searchStatements();
  $(".date").css("color", "pink");  //Will change existing .date elements' color
});

However, since searchStatements() runs an ajax query to fetch results, you should update the color after it's finished. Have a look at jQuery's .ajaxComplete()

periklis
  • 10,102
  • 6
  • 60
  • 68
  • Tried moving the update below SearchStatements. Issue is its manipulating content that is only part of the DOM once the command has concluded. So does nothing. .ajaxComplete looks more likely. Will investigate. Thanks. – user2284913 Apr 16 '13 at 06:44