Search code examples
jsviews

JsView Retrieve the view associated to a data item


If I want to find the underlying data that powers a view, I would write something like:

var actualData = $.view(this).data;

However if I want to find the view associated to a data, how can I achieve this? Something like this:

var view = $.view(actualData).view;

Edit 1

I found an issue posted on GitHub that was very similar to what I am asking in this question. The solution to that issue was to traverse through the entire DOM hierarchy and to compare the data items of each view with the target data item. Due to that issue opened in 2011, I am leaving this question open in case there have been any developments made to JsViews that can allow this to be done without traversing through the DOM hierarchy. https://github.com/BorisMoore/jsviews/issues/14


Solution

  • In case someone runs into a similar situations like me, this is currently not possible.

    At the moment, my workaround for this limitation is if I feel the need to access the view of a data item, then I add it to my object as a property.