Click here to Skip to main content
15,888,351 members
Home / Discussions / JavaScript
   

JavaScript

 
AnswerRe: What does ".then" mean in JavaScript? Pin
Richard Deeming23-Feb-18 0:58
mveRichard Deeming23-Feb-18 0:58 
QuestionHow do I make a pop-up window in JavaScript? Pin
Xarzu21-Feb-18 12:34
Xarzu21-Feb-18 12:34 
AnswerRe: How do I make a pop-up window in JavaScript? Pin
Peter_in_278021-Feb-18 17:16
professionalPeter_in_278021-Feb-18 17:16 
AnswerRe: How do I make a pop-up window in JavaScript? Pin
Richard Deeming22-Feb-18 0:40
mveRichard Deeming22-Feb-18 0:40 
Questionhow to add col dynamically using js and html Pin
Member 1368695921-Feb-18 1:03
Member 1368695921-Feb-18 1:03 
AnswerRe: how to add col dynamically using js and html Pin
Richard MacCutchan21-Feb-18 2:03
mveRichard MacCutchan21-Feb-18 2:03 
AnswerRe: how to add col dynamically using js and html Pin
ZurdoDev21-Feb-18 9:02
professionalZurdoDev21-Feb-18 9:02 
QuestionUsing JQuery on and off for events Pin
jkirkerx20-Feb-18 13:17
professionaljkirkerx20-Feb-18 13:17 
I'm seemed to be confused here with on and off. With Setting the event and then turning them off during an $.Ajax function
In my $(document).ready, I do the bind, or On. I was using .click
$(document).on("change", "#Shipper_VendorID", function () {
        load_rateAPICodes();
    });

    $(document).on("change", "#Shipper_RateAPICode", function () {
        load_RateAPIDetails();
    });

When I had declared the function here, the function was firing during unload so I removed the function
beforeSend: function () {
  // Unbind Events if the Vendor has changed            
  $(document).off("change", $ddl_vendorID);
  $(document).off("change", $ddl_serviceID);            
},

Here I rebind the function, but it fires the function I'm trying to bind.
complete: function () {
  // Rebind the Events that were unbinded if the vendor was changed            
  $(document).on("change", $ddl_vendorID, load_rateAPICodes());
  $(document).on("change", $ddl_serviceID, load_RateAPIDetails());                        
}

I guess I don't understand why on and off fires the function when I just want to ignore the bind.

This is the whole function in case your wondering what I'm doing here.
You click on a radio button item in a group and I fetch the vendor and service, and then run another $.Ajax to get the service maximum parameters.
But if the vendor is different, I have to reload the services that match that vendor, and then select the service which isn't working well for me.
I just too much going on here.
function run_packageSelect(_packageID) {

    var $txt_orderID                    = $("#Order_ID"),<br />
        $ddl_vendorID                   = $("#Shipper_VendorID"),
        $ddl_serviceID                  = $("#Shipper_RateAPICode"),
        $js_packageAdd                  = $("#js_packageAdd"),
        _dataVendorID                   = $("#Shipper_VendorID option:selected").attr("value"),
        _dataVendorAttr                 = $ddl_serviceID.attr("data-vendor");

    // Collapse the Package Form
    $js_packageAdd.collapse('hide');

    $.ajax({
        type: "POST",
        cache: true,
        dataType: "json",
        global: true,
        url: '/Ajax/Json_Shipment_Order_Package_Fetch',
        data: { Package_ID: parseInt(_packageID, 10) },
        beforeSend: function () {
            // Unbind Events if the Vendor has changed<br />
            $(document).off("change", $ddl_vendorID);
            $(document).off("change", $ddl_serviceID);<br />
        },
        error: function (response) {<br />
            alert("http code: " + response.status + " Error: Json_Shipment_Order_Package_Fetch - data: " + response);
        },
        success: function (data) {

            // Update the Dropdown boxes if the vendor has changed
            $ddl_vendorID.val(data.Vendor_ID); 
            if (parseInt(_dataVendorID, 10) !== parseInt(_dataVendorAttr, 10)) {

                $.ajax({
                    type: "POST",
                    cache: true,
                    dataType: "json",
                    url: '/Ajax/Json_Shipment_Load_Vendor_Services',
                    global: true,
                    data: { ShipperID: parseInt(data.Vendor_ID, 10) },
                    error: function (response) {
                        alert("http code: " + response.status + " Error: Json_Order_Shipment_Load_Services - data: " + response);
                    },
                    success: function (data) {
                        var markup = "<option value=''> " + data.length + " services(s) found --</option>";
                        for (var x = 0; x < data.length; x++) {
                            if (data.Value == data.Service_ID) {
                                markup += "<option value=" + data[x].Value + " selected>" + data[x].Text + "</option>";
                            }
                            else {
                                markup += "<option value=" + data[x].Value + ">" + data[x].Text + "</option>";
                            }
                        }
                        $("#Shipper_RateAPICode").html(markup).show();
                    },
                    complete: function () {
                        $ddl_serviceID.val(data.Service_ID).change();
                    }
                });
            }
            else {
                $ddl_serviceID.val(data.Service_ID).change();
            }
        },
        complete: function () {
            // Rebind the Events that were unbinded if the vendor was changed<br />
            $(document).on("change", $ddl_vendorID, load_rateAPICodes());
            $(document).on("change", $ddl_serviceID, load_RateAPIDetails());<br />
        }
    });
}
If it ain't broke don't fix it

AnswerRe: Using JQuery on and off for events Pin
Richard Deeming21-Feb-18 8:07
mveRichard Deeming21-Feb-18 8:07 
GeneralRe: Using JQuery on and off for events Pin
jkirkerx22-Feb-18 7:31
professionaljkirkerx22-Feb-18 7:31 
Questionnodejs and WSDL Pin
dfgdsgjghiouyiouyol19-Feb-18 0:43
dfgdsgjghiouyiouyol19-Feb-18 0:43 
Question(NodeJS) ejs ignoring if statement if a css class is added to the element Pin
random_xyz12-Feb-18 5:08
random_xyz12-Feb-18 5:08 
QuestionJquery: How to conditionally attach/detach bootstrap datepicker with textbox Pin
Mou_kol7-Feb-18 8:17
Mou_kol7-Feb-18 8:17 
AnswerRe: Jquery: How to conditionally attach/detach bootstrap datepicker with textbox Pin
Mou_kol7-Feb-18 8:22
Mou_kol7-Feb-18 8:22 
Questionjquery addClass and removeClass not working Pin
Mou_kol5-Feb-18 22:47
Mou_kol5-Feb-18 22:47 
AnswerRe: jquery addClass and removeClass not working Pin
Richard Deeming6-Feb-18 2:29
mveRichard Deeming6-Feb-18 2:29 
GeneralRe: jquery addClass and removeClass not working Pin
Mou_kol6-Feb-18 2:45
Mou_kol6-Feb-18 2:45 
GeneralRe: jquery addClass and removeClass not working Pin
Richard Deeming6-Feb-18 2:54
mveRichard Deeming6-Feb-18 2:54 
GeneralRe: jquery addClass and removeClass not working Pin
Mou_kol7-Feb-18 20:43
Mou_kol7-Feb-18 20:43 
GeneralRe: jquery addClass and removeClass not working Pin
Richard Deeming8-Feb-18 0:51
mveRichard Deeming8-Feb-18 0:51 
GeneralRe: jquery addClass and removeClass not working Pin
Mou_kol8-Feb-18 1:18
Mou_kol8-Feb-18 1:18 
GeneralRe: jquery addClass and removeClass not working Pin
Richard Deeming8-Feb-18 1:23
mveRichard Deeming8-Feb-18 1:23 
QuestionAutomatic calculation of Days and Filling of Months, Year Pin
Kiran Kumar31-Jan-18 9:13
Kiran Kumar31-Jan-18 9:13 
AnswerRe: Automatic calculation of Days and Filling of Months, Year Pin
F-ES Sitecore1-Feb-18 0:12
professionalF-ES Sitecore1-Feb-18 0:12 
QuestionEdit an Embed COde Api to implement on a website Pin
Member 1363973526-Jan-18 18:32
Member 1363973526-Jan-18 18:32 

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.