jquery selector syntax

jquery selector syntax

montoyammontoyam Posts: 568Questions: 136Answers: 5
edited December 2020 in Editor

I have a feeling I am going to slap myself after I get the answer because it will be so obvious, but I am just blanking out.

I am looking to select all the inputs in an Editor but I can't figure out the syntax for a jquery select statement

            var SystemUsersLineItemsEditor = new $.fn.dataTable.Editor({
                ajax: 'api/SystemUsersLineItems?systemUserID=' + rowID,
                table: table,
                fields: [
                    { label: "Staff", name: "SystemUsers_LineItems.SystemUserID", type: "select", def: rowID },
                    {
                        label: "Line Item:"
                        , name: "SystemUsers_LineItems.LineItemID"
                        , type: "select"
                        , placeholder: "<Select a Line Item>"
                        , placeholderValue: 0
                        , placeholderDisabled: false
                        , className: 'myClass'

                    },
                    {
                        label: "Fund/Org:"
                        , name: "SystemUsers_LineItems.FundOrgID"
                        , type: "select"
                        , placeholder: "<Select a Fund/Org>"
                        , placeholderValue: 0
                        , placeholderDisabled: false
                        , className: 'myClass'
                    },

                    {
                        label: "Effective Date:"
                        , name: "SystemUsers_LineItems.EffectiveDate"
                        , type: 'datetime'
                        , format: "M/D/YYYY"
                        , def: AsOfCookie
                        , className: 'myClass'
                    },
                    {
                        label: "Expire Date:"
                        , name: "SystemUsers_LineItems.ExpireDate"
                        , type: 'datetime'
                        , format: "M/D/YYYY"
                        , className: 'notMyClass'
                    }
                ]
            });
            SystemUsersLineItemsEditor.on('opened', function (e, node, data, items, type) {
                var lineItem = SystemUsersLineItemsEditor.get('SystemUsers_LineItems.LineItemID');
                var effectiveDate = SystemUsersLineItemsEditor.get('SystemUsers_LineItems.EffectiveDate');
                var headerIsBilled = isBilled(effectiveDate, 0, 0, 0, lineItem, 0);
                console.log(headerIsBilled);
                $(the editor object).find(":input").attr('readonly', headerIsBilled);
                $(the editor object).find("select").attr('disabled', headerIsBilled);
                //SystemUsersLineItemsEditor.disable('SystemUsers_LineItems.EffectiveDate');
                SystemUsersLineItemsEditor.enable('SystemUsers_LineItems.ExpireDate');
            });

So, my question is regarding line numbers 6 and 7 above. I added classes and can disable using the className, but I need to do this for every Editor in my project (probably 50+) so I would like something more dynamic and not want to go in and add classes to each field.

Answers

  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    a co-worker was able to guide me to the solution. here is the final version:

            function lockEditorFields(editorObject, expireDateField, headerIsBilled) {
                $("form .DTE_Form_Content :input").prop('disabled', headerIsBilled);
                editorObject.enable(expireDateField);
            }
    
                SystemUsersLineItemsEditor.on('opened', function (e, node, data, items, type) {
                    var lineItem = SystemUsersLineItemsEditor.get('SystemUsers_LineItems.LineItemID');
                    var effectiveDate = SystemUsersLineItemsEditor.get('SystemUsers_LineItems.EffectiveDate');
                    var headerIsBilled = isBilled(effectiveDate, 0, 0, 0, lineItem, 0);
                    lockEditorFields(this, 'SystemUsers_LineItems.ExpireDate', headerIsBilled);
                });
    
This discussion has been closed.