Click here to Skip to main content
15,890,690 members
Home / Discussions / JavaScript
   

JavaScript

 
GeneralRe: I am not sure why this controller is not firing in this AngularJS script, any help Pin
indian14322-May-16 0:38
indian14322-May-16 0:38 
GeneralRe: I am not sure why this controller is not firing in this AngularJS script, any help Pin
Karthik_Mahalingam22-May-16 0:39
professionalKarthik_Mahalingam22-May-16 0:39 
GeneralRe: I am not sure why this controller is not firing in this AngularJS script, any help Pin
indian14322-May-16 0:49
indian14322-May-16 0:49 
GeneralRe: I am not sure why this controller is not firing in this AngularJS script, any help Pin
indian14322-May-16 0:46
indian14322-May-16 0:46 
GeneralRe: I am not sure why this controller is not firing in this AngularJS script, any help Pin
Karthik_Mahalingam22-May-16 0:51
professionalKarthik_Mahalingam22-May-16 0:51 
GeneralRe: I am not sure why this controller is not firing in this AngularJS script, any help Pin
indian14322-May-16 1:13
indian14322-May-16 1:13 
GeneralRe: I am not sure why this controller is not firing in this AngularJS script, any help Pin
Karthik_Mahalingam22-May-16 1:16
professionalKarthik_Mahalingam22-May-16 1:16 
QuestionUsing JQuery $.when, addng a promise to each function so When knows its done. Pin
jkirkerx5-May-16 12:12
professionaljkirkerx5-May-16 12:12 
I have this function that writes HTML5 in a MVC View, then it populates the 5 select elements.
But I want to make sure the elements are populated first before I set the data record in it.
I have a problem with the last select element not having it's value selected, so I suspect the options haven't completed yet.

So I tried this, but it won't magically work without me modifying each function with a promise or something.
The first promise was easy to figure out, but adding a promise to my $Ajax function seems more complicated.
I have no clue how to add the promise to the 3nd code sample.

load_cardData_update_record(_paymentID) // Final Ajax call is the final $Ajax call that grabs the record.
Maybe I'm going about this wrong. Perhaps I should grab the record first before writing all this HTML to the DOM.
$uContainer.empty().html(uElements).show().promise().done(function (arg1) {
        select_cardBrands('CreditDebitRecord_Update_Card_Brand');
        select_expMonths('CreditDebitRecord_Update_Card_ExpMonth');
        select_expYears('CreditDebitRecord_Update_Card_ExpYear');
        load_updateCard_countryCodes();
        load_updateCard_stateCodes("US");

        $.when( select_cardBrands(), select_expMonths(), select_expYears(), load_updateCard_countryCodes(), load_updateCard_stateCodes() ).then(load_cardData_update_record(_paymentID));

        // Rebind the Change Country Code
        $("#CreditDebitRecord_Update_BillingAddress_CountryCode").change(function () {
            var _countryCode = $("#CreditDebitRecord_Update_BillingAddress_CountryCode option:selected").val();
            load_updateCard_stateCodes(_countryCode);
        });

        $("#CreditDebitRecord_Update_Card_Name").focus();
    });    

And a sample function that uses $Ajax and needs a promise.
function select_cardBrands(_parent) {
    var $select                     = $('#' + _parent),
        option                      = '';

    $.ajax({
        type: "POST",
        cache: false,
        dataType: "json",
        url: '/Ajax/json_select_load_cardBrands',
        data: { },
        error: function (response) {
            debugger;
            alert("http code: " + response.status + " Error: json_select_load_cardBrands - data: " + response);
            $e_UpdateCreditDebit.toggleClass('active');
        },
        success: function (data) {
            for (var x = 0; x < data.length; x++) {
                option += '<option value="' + data[x].value + '">' + data[x].text + '</option>';
            }
            $select.html(option);
        }
    });
}

AnswerI think I might have it now, not sure if its the right way to do it, but it works. Pin
jkirkerx5-May-16 13:38
professionaljkirkerx5-May-16 13:38 
GeneralRe: I think I might have it now, not sure if its the right way to do it, but it works. Pin
Nathan Minier6-May-16 1:50
professionalNathan Minier6-May-16 1:50 
GeneralRe: I think I might have it now, not sure if its the right way to do it, but it works. Pin
jkirkerx6-May-16 5:27
professionaljkirkerx6-May-16 5:27 
GeneralRe: I think I might have it now, not sure if its the right way to do it, but it works. Pin
Nathan Minier6-May-16 6:14
professionalNathan Minier6-May-16 6:14 
GeneralRe: I think I might have it now, not sure if its the right way to do it, but it works. Pin
jkirkerx6-May-16 7:28
professionaljkirkerx6-May-16 7:28 
QuestionNeed an API similar to YouTube Help popup window Pin
Zaki Gaima5-May-16 3:28
Zaki Gaima5-May-16 3:28 
Questionbrowser error handling using javascript Pin
rorschach2174-May-16 19:25
rorschach2174-May-16 19:25 
SuggestionRe: browser error handling using javascript Pin
Richard MacCutchan4-May-16 20:58
mveRichard MacCutchan4-May-16 20:58 
AnswerRe: browser error handling using javascript Pin
John C Rayan13-May-16 1:18
professionalJohn C Rayan13-May-16 1:18 
QuestionAsynchronouse Call Pin
Syed Rehman27-Apr-16 9:14
Syed Rehman27-Apr-16 9:14 
QuestionRe: Asynchronouse Call Pin
ZurdoDev27-Apr-16 9:29
professionalZurdoDev27-Apr-16 9:29 
AnswerRe: Asynchronouse Call Pin
John C Rayan4-May-16 22:20
professionalJohn C Rayan4-May-16 22:20 
Questionhelp me writing a small program Pin
Member 1248677626-Apr-16 10:36
Member 1248677626-Apr-16 10:36 
AnswerRe: help me writing a small program Pin
Afzaal Ahmad Zeeshan26-Apr-16 11:00
professionalAfzaal Ahmad Zeeshan26-Apr-16 11:00 
AnswerRe: help me writing a small program Pin
Peter_in_278026-Apr-16 21:05
professionalPeter_in_278026-Apr-16 21:05 
GeneralRe: help me writing a small program Pin
Karthik_Mahalingam5-May-16 23:27
professionalKarthik_Mahalingam5-May-16 23:27 
QuestionHelp me to write a small program. Pin
Member 1248677626-Apr-16 10:21
Member 1248677626-Apr-16 10:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.