Hello,
I am involved in a JavascriptMVC v.3.2 project and recently I had to deal with this situation.
$.Controller('ATable', {} , {
...
validateNow: function() {
...
//some 'synchronous' validations i.e. 'input' fields value checking
...
return true or false;
}
I am involved in a JavascriptMVC v.3.2 project and recently I had to deal with this situation.
$.Controller('ATable', {} , {
...
validateNow: function() {
...
//some 'synchronous' validations i.e. 'input' fields value checking
...
return true or false;
}
});
$.Controller('APage', {} , {
init: function () {
...
this.find('atable_placeholder').a_table();
...
},
'.savebtn click': function() {
//should somehow call validateNow
if ( validateNowResponse === true ) {
doSaveStuff();
}
},
'.sendtobtn click': function() {
//should somehow call validateNow
if ( validateNowResponse === true ) {
doSendToStuff();
}
}
});
My question is related to a proper manner to deal with calling ATable's 'validateNow' method inside of APage, having controller decoupling in mind.
For the moment I solved the problem with an
var validateNowResponse = this.find('atable_placeholder').controller().validateNow();
approach in both click functions. It was the simplest and easiest for me to do so, but it creates a somehow intimate relation between the 2 controllers.
I am still wondering if there are some other more JavascriptMVC-esque techniques to deal with this kind of situations (perhaps trigger-response messages?). Do you have any ideas?
Thanks in advance,
Mec
$.Controller('APage', {} , {
init: function () {
...
this.find('atable_placeholder').a_table();
...
},
'.savebtn click': function() {
//should somehow call validateNow
if ( validateNowResponse === true ) {
doSaveStuff();
}
},
'.sendtobtn click': function() {
//should somehow call validateNow
if ( validateNowResponse === true ) {
doSendToStuff();
}
}
});
My question is related to a proper manner to deal with calling ATable's 'validateNow' method inside of APage, having controller decoupling in mind.
For the moment I solved the problem with an
var validateNowResponse = this.find('atable_placeholder').controller().validateNow();
approach in both click functions. It was the simplest and easiest for me to do so, but it creates a somehow intimate relation between the 2 controllers.
I am still wondering if there are some other more JavascriptMVC-esque techniques to deal with this kind of situations (perhaps trigger-response messages?). Do you have any ideas?
Thanks in advance,
Mec