I have developed an app with jquery-mobile. Now I am trying to setup a jasmine framework for it.
In original code, I am creating a listview dynamically. After appending items to `ul.list`, I
am calling `ul.list.listview('refresh');`
This is working as expected in main app.
I have added different UTs, to check behavior of different events on this list. So every time I am calling populate function to load this list.
The general structure of my jasmine code is:
describe("List behavior", function() {
beforeEach(function(){
var obj = new listObj({});
loadFixtures('list.html');
$('ul.list').trigger('create');
});
it("should ...", function() {
obj.populate(somelist);
.
.
});
it("should ...", function() {
obj.populate(somelist);
.
.
});
it("should ...", function() {
obj.populate(somelist);
.
.
});
});
Code for populate method is
this.populate = function(somelist) {
$('ul.list').append(somelist).listview('refresh');
};
When the line comes 'listview('refresh')', it gives error as `Uncaught Error: cannot call methods on listview prior to initialization; attempted to call method 'refresh' `
though I am creating listview before each test execution. And then all my succeding tests fail.
Things I tried and their results :
1. I tried just assigning `'ui-listview'` to the `ul.list`, and not creating listview. Still it didn't work.
2. I tried `$('ul.list').listview()`, it gives error as `TypeError: Cannot read property 'jQuery110203482820538338274' of undefined`. But this assigns required class to the ul.
Can any one suggest me some workaround so that I can execute all tests without this error?
Thanks.