magento2 – Knockout linked to the template

I'm trying to make the input field in my custom form element, like


but then I get errors from JS because Elem user changes and others do not exist (see https://github.com/magento/magento2/blob/2.3-develop/app/code/Magento/Ui/view/base/web/templates/form/ element / input.html), how can I bind a js component to render a model, or how can I use a form element in another form element?

javascript – HttpPostedFileBase null when i'm trying to download a .net mvc5 asp image with js knockout?

I'm trying to load images in asp .net mvc 5 with knockout js and the paraFrame PhotoFile which is of type HttpPostedFileBase is null, and i can not upload the image, i am working again with Knockout js. I would like someone to help me with that

That's the model

                public int LenderId {get; together; }
public channel GenderId {get; together; }
public string GenderName {get; together; }
public channel Email {get; together; }
public bool IsActive {get; together; }
public channel PhotoPath {get; together; }
public HttpPostedFileBase PhotoFile {get; together; }

That's the html,

        
Photo:

It's javascript,

function lenderModel () {
var lenderModel = this;

lenderModel.LenderId = ko.observable ();
lenderModel.FirstName = ko.observable ();
lenderModel.MiddleName = ko.observable ();
lenderModel.FirstLastName = ko.observable ();
lenderModel.SecondLastName = ko.observable ();
lenderModel.IdentificationCard = ko.observable ();
lenderModel.GenderId = ko.observable ();
lenderModel.GenderName = ko.observable ();
lenderModel.Email = ko.observable ();
lenderModel.IsActive = ko.observable ();
lenderModel.PhotoPath = ko.observable ();
lenderModel.CreateBy = ko.observable ();
lenderModel.CreationDate = ko.observable ();
lenderModel.ModifiedBy = ko.observable ();
lenderModel.ModifiedDate = ko.observable ();

}

lenderViewModel.Create = function () {
if (lenderViewModel.IsNew ()) {
$ .ajax ({
url: & # 39; / # / AdminLenders / Create & # 39;
data: ko.toJSON (lenderViewModel.LenderModel ()),
dataType: "json",
type: "POST",
contentType: "application / json; charset = utf-8",
async: true,
success: function (data) {
if (data.Success) {
LoadGenders ();
LoadListLenders ();
$ (# TextboxFirstName & # 39;). Val (& # 39;);
$ (# TextboxMiddleName & # 39;). Val (& # 39;);
$ (# TextboxFirstLastName & # 39;). Val (& # 39;);
$ (# TextboxSecondLastName & # 39;). Val (& # 39;);
$ (# TextboxIdentificationCard & # 39;). Val (& # 39;);
$ (# TextboxEmail #); Val (& # 39;);
$ (# ComboBoxGenders & # 39;). Val (& # 39;);
$ (# TextboxIsActive & # 39;). Prop (& # 39; verified & # 39; false);
swal ("lender created!", "you have successfully registered!", "successful")
}
if not {
swal ("Error creating lender!", data.Data, "error")
}
}
error: function (ex) {
alert (& # 39; occurring an error & # 39;);
}
});
}
};

As a novice in this field, I do not know how I can apply it, I help to appreciate the contribution and help.

magento2 – Magento 2: knockout data-bind: the click does not work

I've added the phtml file using an ajax response. There are two buttons available in this phtml file.

Buttons.phtml:

MainFile.phtml:

This Buttons.phtml file added to

using an ajax response.

Now when to click Selection button then addCustomOptions () function call should be call. But it does not work.

Or I'm wrong?

Help me, please.

Thank you.

magento2 – How to specify the path of the image relative to the module in the HTML view of Knockout?

I am doing a magento 2 module, usign 2.2.6, trying to display some information at the checkout and I am stuck when trying to add an image to the path of the module.

I do not use PHTML in this case, and I try not to have to

FYI: I've read the question How to specify the skin image path in the HTML Knockout template?

And this one is used to obtain images relating to the path of the theme, not to the module.

magento2.2 – AutoComplete Form Field Using Knockout Js on Magento2 Checkout

I have created a module that automatically completes the Magento City field. I'm facing a problem that says

TypeError: Can not process link "shippingAutoComplete: function () {return {
selected: selectedCity, options: getCities}} "

enter the description of the image here

I referred this thread to create my module Validation Error with jQuery-UI Autocomplete and KnockoutJs – Magento 2

Please let me know what mistakes I'm making here

Here is my module code:

    & # 39; Vendor_ModuleName / js / shippingAutoComplete & # 39;
& # 39; config & # 39; =>[
& # 39; customScope & # 39; => & # 39; shippingAddress & # 39;
& # 39; template & # 39; => Ui / form / field & # 39;
& # 39; elementTmpl & # 39; => & # 39; Vendor_ModuleName / autocomplete / shippingAddress / cityInput & # 39;
& # 39; id & # 39; => & # 39 ;, city
& # 39; tooltip & # 39; =>[
& # 39; description & # 39; => & # 39; Select a city.
],
],
& # 39; dataScope & # 39; => & # 39; shippingAddress.city & # 39 ;,
& # 39; Label & # 39; => & # 39 ;, Town
& # 39; provider & # 39; => & # 39; checkoutProvider & # 39;
& # 39; sortOrder & # 39; => 53,
& # 39; validation & # 39; => [
                'required-entry' => true
            ],
& # 39; Options & # 39; => [],
& # 39; visible & # 39; => true,
];

$ jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
        ['shippingAddress']['children']['shipping-address-fieldset']['children']['city']    = $ cityField;

return $ jsLayout;
}
}

app / code / Vendor / ModuleName / view / frontend / web / js / shippingAutoComplete.js

to define([
    'Magento_Ui/js/form/element/abstract',
    'mage/url',
    'ko',
    'jquery',
    'jquery/ui'
], function (Summary, url, ko, $) {
& # 39; use strict & # 39 ;;

ko.bindingHandlers.shippingAutoComplete = {
init: function (element, valueAccessor) {
var settings = valueAccessor ();
var selectedOption = settings.selected;
var options = settings.options;
var updateElementValueWithLabel = function (event, ui) {
event.preventDefault ();
$ (element) .val (ui.item.label);
if (typeof ui.item! == "undefined") {
selectedOption (ui.item);
}
};

$ (element) .autocomplete ({
source: options,
select: function (event, user interface) {
updateElementValueWithLabel (event, ui);
}
});
}
};

returns Abstract.extend ({
selectedCity: ko.observable (& # 39;),
getCities: function (request, response) {
$ .ajax ({
url: url.build (& # 39; list / check / cities / & # 39;),
data: JSON.stringify ({
q: request.term
}),
contentType: "application / json",
type: "POST",
dataType: & quot; json & # 39;
error: function () {
alert ("An error has occurred.");
}
success: function (data) {
// Data is a string of the form: & # 39;[{"label": label, "value": value}]& # 39;
response (data);
}
});
}
});
});

app / code / Vendor / ModuleName / view / frontend / web / template / autocomplete / shippingAddress / cityInput.html


magento2 – Knockout for each afterRender

How can I call afterRender after generating all foreach elements? I want to initialize the cursor after rendering all slides.

I have tried:


but put console.log (jQuery (& # 39;. slide & # 39;). length) in the renderDelivery function. Sometimes he writes 0 elements, sometimes all generated. renderDelivery triggers those.