을 완료, 그 버튼을 클릭에 내가 필요 : JQuery와 대기가 나는 버튼이
- 는
- 이 팝업을 표시해야하는 방법을 실행합니다.
코드는 다음과 같습니다
$('.dwnSingleImageLink').live('click', function(event){
$('html, body').animate({scrollTop : 0}, 'slow');
singleFileDownload = true;
var renditions = getRenditionResultset($(this).attr('data-id'), $(this).attr('data-docname'));
for(var i = 0; i < renditions.length; i++){
var name = renditions[i].name;
if(name == 'Web' || name == 'Thumbnail' || name == 'Preview' || name == 'Native File'){
var info = {
name: renditions[i].name,
fileSize: renditions[i].fileSize,
width: renditions[i].width,
height: renditions[i].height,
label: ''
};
renditionInfos.push(info);
}
}
$('#downloadModal').find('input:hidden').attr({
'data-id': $(this).attr('data-id'),
'data-docname': $(this).attr('data-docname'),
'data-title': $(this).attr('data-title')
}).after(function(){
$('#downloadModal').modal('show').css({
width: '380px',
'margin-left': function() {
return - ($(this).width()/2);
}
});
});
});
var getRenditionResultset = function(dID, dDocName){
var submitData = {
IdcService: 'RENDITION_INFO',
dID: dID,
dDocName: dDocName
};
var renditions = new Array();
var fields = new Array();
$.ucm.executeServiceIsJson(submitData, function(ucmResponse) {
var resultSet = ucmResponse.ResultSets['manifest'];
alert('jym');
for (var fieldIndex = 0; fieldIndex < resultSet.fields.length; fieldIndex++) {
var field = new RenditionField();
field.name = resultSet.fields[fieldIndex].name;
field.index = fieldIndex;
fields.push(field);
}
for(var rowIndex = 0; rowIndex < resultSet.rows.length; rowIndex++) {
var rendition = new Rendition();
for(var i = 0; i < fields.length; i++){
var value = resultSet.rows[rowIndex][fields[i].index];
switch(fields[i].name){
case 'extRenditionName' :
rendition.name = value;
break;
case 'extRenditionDescription' :
rendition.description = value;
break;
case 'extRenditionPath' :
rendition.path = value;
break;
case 'extRenditionOriginalName' :
rendition.originalName = value;
break;
case 'extRenditionParams' :
rendition.params = value;
break;
case 'extRenditionType' :
rendition.type = value;
break;
case 'extRenditionFileSize' :
rendition.fileSize = value;
break;
case 'extRenditionWidth' :
rendition.width = value;
break;
case 'extRenditionHeight' :
rendition.height = value;
break;
case 'extRenditionFileType' :
rendition.fileType = value;
break;
case 'extRenditionPixelsPerInchVertical' :
rendition.pixelsPerInchVertical = value;
break;
case 'extRenditionPixelsPerInchHorizontal' :
rendition.pixelsPerInchHorizontal = value;
break;
case 'extRenditionColours' :
rendition.colours = value;
break;
}
}
renditions.push(rendition);
}
});
return renditions;
}
function RenditionField() {
this.name = '';
this.index = -1;
}
function Rendition() {
this.name = '';
this.description = '';
this.path = '';
this.originalName = '';
this.params = '';
this.type = '';
this.fileSize = '';
this.width = '';
this.height = '';
this.fileType = '';
this.pixelsPerInchVertical = '';
this.pixelsPerInchHorizontal = '';
this.colours = '';
}
Rendition.prototype.toString = function() {
return '[object Rendition: name=' + this.name + ';description=' + this.description + ';path=' + this.path + ';originalName=' + this.originalName +
';params=' + this.params + ';type=' + this.type + ';fileSize=' + this.fileSize + ';width=' + this.width + ';height=' + this.height + ';fileType=' +
this.fileType + ';pixelsPerInchVertical=' + this.pixelsPerInchVertical + ';pixelsPerInchHorizontal=' + this.pixelsPerInchHorizontal + ';colours=' +
this.colours + ']';
}
그것은 큰 코드입니다. 그것이하는 일은 아약스 요청을 보내고 응답을받는 것입니다. 그런 다음 응답을 처리하고 배열을 만듭니다. 이것들은 방법 getRenditionResultset()
의 작업입니다. 그러나 배열을 생성하기 전에 내 응용 프로그램에서이 메서드를 호출하면 for 루프가 show modal 블록을 실행합니다. getRenditionResultset()
메서드의 끝을 기다린 다음 for 및 click
처리기의 나머지 코드를 어떻게 실행합니까? 이 경우 $.when()
을 사용할 수 있습니까? 감사합니다.
'live'는 대신 ['on' (http://api.jquery.com/on/)을 중단한다. –
@arxanas, 제안에 감사드립니다, 나는 그것을 바꿀 것입니다. 그러나 일부 컨테이너의 내용을 동적으로 대체하는 경우에는 해당 컨테이너의 요소가 바인딩 방법을 잃어 버렸습니다. 이 경우 라이브가 잘 작동합니다. –
'on'도 똑같은 일을하지만 좀 더 일반적입니다. 그것은 당신이'live'의 기능을 복제 할 수있게 해주 며, 또한 여러분은 버블 링 된 이벤트와 다른 것들을 잡을 수 있습니다. –