Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Trying to write a general function to set the selection state in another app when writing mashups.
var stateListener = function(theApp) {
theApp.clearAll();
var selFields = this.selections;
if (selFields!=null){
$.each(selFields, function(key, value) {
var valArray=[];
$.each(value.selectedValues, function(key,value){
valArray.push(value.qName);
})
theApp.field(value.fieldName).selectValues(valArray, true, true);
});
}
};
So trying to use it like this:
var selState = app.selectionState( ); //get state of app
selState.OnData.bind( stateListener, app1 ); //bind to function with argument of app1 to set it's state
But it's not calling the listener.
Ideas appreciated!
Found a work-around but not that happy with it. Instead of an argument I set a global scope var to the application:
var theApp;
function stateListener() {
theApp.clearAll();
var selFields = this.selections;
if (selFields!=null){
$.each(selFields, function(key, value) {
var valArray=[];
$.each(value.selectedValues, function(key,value){
valArray.push(value.qName);
})
theApp.field(value.fieldName).selectValues(valArray, true, true);
});
}
}
and use the function like:
var selState = app.selectionState( ); //get state of app
theApp = app1; //set global to app1
selState.OnData.bind( stateListener ); //bind to function
Found a work-around but not that happy with it. Instead of an argument I set a global scope var to the application:
var theApp;
function stateListener() {
theApp.clearAll();
var selFields = this.selections;
if (selFields!=null){
$.each(selFields, function(key, value) {
var valArray=[];
$.each(value.selectedValues, function(key,value){
valArray.push(value.qName);
})
theApp.field(value.fieldName).selectValues(valArray, true, true);
});
}
}
and use the function like:
var selState = app.selectionState( ); //get state of app
theApp = app1; //set global to app1
selState.OnData.bind( stateListener ); //bind to function