Giter Site home page Giter Site logo

Comments (7)

timstuyckens avatar timstuyckens commented on September 21, 2024

Can you provide some details about the setup, what is different than the knockout.js samples?
*Are you using AMD?
*Any external templating engine? (if so, there are setups that have problems #9)

Is the website public available? That would be great :)

I have put some additional info in the wiki page in case you want to investigate this further.
https://github.com/timstuyckens/chromeextensions-knockoutjs/wiki/Contribute (see Catch )

I also released a new version (2.3) that contains some additional error handling ( cab93a7 and 4e08bfd ) . This might show the root cause.

from chromeextensions-knockoutjs.

devguydavid avatar devguydavid commented on September 21, 2024

I'm not using AMD nor an external template engine.

You can access the site at http://cms.uplynk.com/static/cms/index.html. You will have to sign up for a new account, or I can set up a test account for you if you'd like.

I will continue to investigate with the new version you've put out, too.

from chromeextensions-knockoutjs.

devguydavid avatar devguydavid commented on September 21, 2024

It looks like

copy["$root_toJS"] = ko.toJS(context[props[i]]);

is causing the problem. ko.toJS() causes the error TypeError: Accessing selectionDirection on an input element that cannot have a selection.

from chromeextensions-knockoutjs.

devguydavid avatar devguydavid commented on September 21, 2024

For future reference: I believe this is because there is a DOM object in there, and DOM elements seem to be notorious for being difficult to serialize because of things like circular references in them.

I'm coming back to javascript after a break of many years, so if I'm wrong here I'm happy to continue digging. But this is my current guess, and I don't know if there's a good way around it at this point. Maybe "scrub" the rootObject that's being processed of any DOM elements before turning it into JS?

from chromeextensions-knockoutjs.

timstuyckens avatar timstuyckens commented on September 21, 2024

Short answer: no quick fix voor $root_toJS, but at least you can see the $data and bounded properties.

Long answer:
Normally you shouldn't have any dom elements in your viewmodel. If you do MVVM 100% correct you will never have to do any jQuery stuff in the viewmodel.

I took a short look at uplynck CMS (which looked really cool) and I think you can improve the knockout code, if you do so, the plugin will also work.

  • First: upgrade to 2.* It has a lot of awesome features, see http://blog.stevensanderson.com/2011/12/21/knockout-2-0-0-released/ for more details
  • You can use point 4 of the blog post to extract the dom manipulation out of the viewmodel
  • For things like popups, creating a custom binding is often a solution. If you use plugins, changes are pretty good somebody already wrote a custom binding.

I don't like the idea of implementing a 'scrub' like thing because it is not the correct way of using knockout.

from chromeextensions-knockoutjs.

devguydavid avatar devguydavid commented on September 21, 2024

I'm actually in the process of moving our CMS to 2.x which is what started me down this path. I appreciate your input and ideas on that. The code is pretty old now and I'm working on bringing it up to "modern" KO.

Fair enough on the scrubbing. I'm still new to KO so I appreciate your insight there, as well.

from chromeextensions-knockoutjs.

timstuyckens avatar timstuyckens commented on September 21, 2024

@cygnl7 You might want to check out the new option: #9 (comment)

from chromeextensions-knockoutjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.