Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249199
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:27:17+00:00 2026-06-07T23:27:17+00:00

I have an element that possesses an attribute whose value is bound to a

  • 0

I have an element that possesses an attribute whose value is bound to a knockout observable:

<text transform='matrix(1 0 0 1 1 1)' data-bind='attr:{transform:textTransform}'></text>

When the element loads I’d like the observable to contain the value defined on the dom element, however it instead loads as undefined and the attribute is removed from the dom element alltogether:

<text data-bind='attr:{transform:textTransform}'></text>

Is it possible to initialize the value of a knockout observable from a dom element attribute and persist the value of the dom element attribute as well?

UPDATE: http://jsfiddle.net/5Z2SC/10/

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:27:18+00:00Added an answer on June 7, 2026 at 11:27 pm

    Another option would be to use a custom binding, and collect the current value of the element in the init function. This is much more reusable, in my opinion.

    ko.bindingHandlers.transform = {
        init: function(element, valueAccessor) {
            valueAccessor()(element.getAttribute('transform'));
        },
        update: function(element, valueAccessor) {
            var value = valueAccessor();
            element.setAttribute('transform', ko.utils.unwrapObservable(value))
        }
    };
    

    Of course, yours will be more complicated, since you must be doing something with this transform property. That logic will probably want to go in the update section.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an element that I'm grabbing the value, thus: var text = form1.elements[i].value;
I have an anchor element that looks like this <a href=url><img src=imgurl/>Text</a> I would
I have some data in an XML element that looks like this: <?xml version=1.0
I have an element that grabs data from mysql. Here is my working code:
I have an element that has -moz-transform applied to it with translateX() , translateY()
I have an element that contains two span tags that each contain some text.
I have a form element that I'm setting as required: $this->addElement('text', 'email', array( 'label'
If I have XAML element that is binded to a data source property and
If have an element that maybe disabled on a page, and would like to
I have an element that can have multiple types (not my design). The element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.