Please help me with this issue. I'm using durandal 2.0, requirejs, knockout and breeze for my spa application. I have a view(options.html) that i want to use as a user control for 3 other views(view1.html,view2.html, and view3.html). Below is the content of the options view.
define(['durandal/app', 'services/logger', 'knockout', 'jquery', 'services/unitofwork'], function (app, logger, ko, $, unitofwork) {
var uow = unitofwork.create();
var substatus = ko.observableArray();
var vm = {
status: substatus,
activate: activate,
startDate: ko.observable(),
endDate: ko.observable(),
attached: function (view, parent) {
var startdatepicker = $(view).find('#startdatediv').datepicker();
var enddatepicker = $(view).find('#enddatediv').datepicker();
var starttxt = $(view).find('#txtstartDate');
var endtxt = $(view).find('#txtendDate');
startdatepicker.on('changeDate', function (ev) {
starttxt.text(startdatepicker.datepicker('getAsText'));
if ((date && date.valueOf()) > (endDate && endDate.valueOf())) {
$('#alert').show().find('strong').text('The start date cannot be after the end date');
} else {
$('#alert').hide();
startDate = date;
}
startdatepicker.datepicker('hide');
});
enddatepicker.on('changeDate', function (ev) {
starttxt.text(startdatepicker.datepicker('getAsText'));
if ((date && date.valueOf()) > (endDate && endDate.valueOf())) {
$('#alert').show().find('strong').text('The start date cannot be after the end date');
} else {
$('#alert').hide();
startDate = date;
}
enddatepicker.datepicker('hide');
});
console.log(startdatepicker.html());
console.log(enddatepicker.html());
}
};
return vm;
function activate() {
return true;
}
function fail(error) {
logger.logError(msg, error, "", true);
}
function getPredicate() {
var predicate = new breeze.Predicate.create("LookupId", "==", 1);
console.log(predicate);
return predicate;
}
});
My problem now is when i try to navigate between the 3 parent views. It seems that the value i selected from the datepicker in the first parent view is recognized in the two other views. How do i achieve the logic where in the options view acts like it has a different id when navigated from the 3 different parent views. Thanks in advance.