var canSaveCookie = (function () {
$.cookie("testSaveCookie", {});
var ok = $.cookie("testSaveCookie") !== null;
$.removeCookie("testSaveCookie");
return ok;
})();
function addTaskList(project_management_id, date) {
$.ajax({
url: "<?= Yii::$app->request->baseUrl ?>/task-detail/ajax-list-task",
dataType: 'json',
data: {'project_management_id' :project_management_id, 'ask_date': date},
type: 'POST',
success: function (res) {
tasks = JSON.parse(res.items);
// defaultEventClick(tasks[0]);
console.log(tasks.length);
// avoid duplicate append task list
clearPopupTaskList();
$.each(tasks, function(id, value) {
$('#popup_task_id')
.append($("<option></option>")
.attr("value", value['id'])
.text(value['task_name']));
});
defaultEventClick(tasks[0]);
handleFileUpload(tasks[0]['id']);
// $('#popup_task_id')
// .append($("<option></option>"))
// .attr("value", '')
// .text('New task');
// fill data
}
});
}
function clearPopupTaskList() {
$('#popup_task_id')
.find('option')
.remove()
.end()
}
Object Find key by value:
Object.prototype.getKeyByValue = function( value ) {
for( var prop in this ) {
if( this.hasOwnProperty( prop ) ) {
if( this[ prop ] === value )
return prop;
}
}
}
$.ajax({
url: "<?= Yii::$app->request->baseUrl ?>/task-detail/ajax-list-task",
dataType: 'json',
data: {'project_management_id' :project_management_id, 'ask_date': date},
type: 'POST',
success: function (res) {
tasks = JSON.parse(res.items);
// defaultEventClick(tasks[0]);
console.log(tasks.length);
// avoid duplicate append task list
clearPopupTaskList();
$.each(tasks, function(id, value) {
$('#popup_task_id')
.append($("<option></option>")
.attr("value", value['id'])
.text(value['task_name']));
});
defaultEventClick(tasks[0]);
handleFileUpload(tasks[0]['id']);
// $('#popup_task_id')
// .append($("<option></option>"))
// .attr("value", '')
// .text('New task');
// fill data
}
});
}
function clearPopupTaskList() {
$('#popup_task_id')
.find('option')
.remove()
.end()
}
Object Find key by value:
Object.prototype.getKeyByValue = function( value ) {
for( var prop in this ) {
if( this.hasOwnProperty( prop ) ) {
if( this[ prop ] === value )
return prop;
}
}
}
Comments
Post a Comment