Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8465457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:03:11+00:00 2026-06-10T15:03:11+00:00

I have a button, on clicking that button I need to: Execute a method

  • 0

I have a button, on clicking that button I need to:

  • Execute a method
  • Need to show a popup.

The code is:

$('.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 + ']';
}

It is a big code. What it does is, send an ajax request and receive the response. Then it process the response and create an array. These are the job of the method getRenditionResultset(). But in my application before the generation of the array the for loop below the invocation of this method get executed also the show modal block. How can I wait for the end of the getRenditionResultset() method and then execute the for and the rest of the code of the click handler? Is there any way to use $.when() in this case?
Regards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T15:03:13+00:00Added an answer on June 10, 2026 at 3:03 pm

    Accept one more callback as parameter to your getRenditionResultset method.

    var getRenditionResultset = function(dID, dDocName, onComplete){ 
    
      $.ucm.executeServiceIsJson(submitData, function(ucmResponse) {
        //after creating the array with the reponse
    
        if(typeof onComplete === function){
           onComplete()
        }
    
    
      }
    }
    

    At the point of invocation, do

    $('.dwnSingleImageLink').on('click', function(event){
     .
     .
         var renditions = getRenditionResultset(blah, blah, function(){
            //code to execute after request has completed.
         }
     .
     .
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a delayed task that runs whenever I click a button. Clicking
I have something like this: $('#find').click(function() {... I need to also add to that
I have a button called as Sync . On clicking on it, I need
I have an button on UIToolbar. i need to display another toolbar on clicking
Imagine you have a template which has a button that by clicking on it,
I have a form submit button that I need to enable the user to
I have a delete button and on clicking cancel on the confirm box, it
I have 2 text boxes and a submit button.On clicking on the submit button
I have an updatepanel which after clicking one button is submitting the page. The
I have a save button in a JFrame ;on clicking save the 'save' text

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.