4

How to change the jquery into ko?

define([
        'jquery'
    ], function ($) {
        "use strict";
        $.widget('xxx.homePage', {
            options: {
                bindSubmit: true,
                sizeGuide: true
                       },
            _create: function () {
                if (this.options.bindSubmit) {
                    this._bindSubmit();
                }
            },
            _bindSubmit: function () {
                var self = this;
                $(window).on('scroll', function () {
                    // View Port top and left dimensions
                    var viewport = {
                        top: $(window).scrollTop(),
                        left: $(window).scrollLeft()
                    };
                    viewport.right = viewport.left + $(window).width();
                    viewport.bottom = viewport.top + $(window).height();


                        if ($('#size-guide').is(":visible")) {
                            var elemtHeight = $('#size-guide').height();// Get the full height of current element
                            elemtHeight = Math.round(elemtHeight);
                            var bounds = $('#size-guide').offset();
                            bounds.top = bounds.top + elemtHeight;
                            bounds.right = bounds.left + $('#size-guide').outerWidth();console.log("OUT");
                            console.log(self.options.sizeGuide);
                            bounds.bottom = bounds.top + $('#size-guide').outerHeight();
                            if (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom)) {
                                if (self.options.sizeGuide) {
                                    self.options.sizeGuide = false;

                                    console.log(self.options.sizeGuide);
                                    self.sizeGuide();

                               }
                            }
                        }
                });});
        return $.xxx.homePage;
    });

            }
  • What you would like to change in js ? – Aasim Goriya Sep 21 '18 at 4:35
  • i would like to change this js into knockout.js – Divya M Sep 22 '18 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.