YUI: DataTable: How to access model's data ?


I'm confused how to access Model's data from a View with a YUI component.What I try to accomplish is to use YUI.DataTable in the index.hb.html (View), but can't figure out how the Model's data is accessed for it within Mojito framework.

In the model I have defined in the "getData"-function my connection to the db. The JSON data is fetched correctly and can be used in the html-block of the view with the mustache notation. But how to reference to this data when a YUI.DataTable is defined in the

5 Replies
  • When you call ac.done(data); data is accessible in mustache variable.

    Mostly you will be executing YUI.DataTable at the client side. For that you have to use binder. In binder you should call your mojit action (say 'X') and then you will get data and then call YUI.dataTable to render

    //binder code
    me.mojitProxy.invoke('X', {'params': {'url': { 'query': '<some query>'}}}, 
    function(err, data) {
                          //do Y.DataTable stuff here

    to ensure that output will be json from server in your controller use

    //dump json (ignore mu template)
    ac.done(data, 'json')

    Read More

    1. Mustache -- http://mustache.github.com/
    2. Screencast Introduction To Yahoo Mojito http://www.youtube.com/watch?v=vNGK9dAq-kc
  • Thanks Singh for your prompt answer.

  • HI,

    I have an odd problem trying to call the data from the Model via the Controller from the Binder using mojitProxy as indicated in your last post. The Mojito version is v0.5.2:

    In the Binder's bind-method I have a listener for the button click. In side of it's handler I have the call the mojitProxy as follows:

                  // Call the controller and fetch the data
                    this.mojitProxy.invoke('doSearch', {params: {id:queryParam1}},function(data){

    On the Chrome console I get this error:

    **Uncaught ReferenceError: mojitProxy is not defined **

    I have been trying to figure out why I can't access it..

    Kind Regards,

  • Arska, just a hunch: this.mojitProxy.invoke within a click listener sounds like this is not pointing to the binder object anymore. You either have to use the var self = this; trick to maintain the reference to the binder object or you use Y.bind to bind the click listener callback to the binder object.

  • Thanx Caridy, that was it... :)


Recent Posts

in Yahoo! Mojito