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

  • SEARCH
  • Home
  • 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 9120635
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:40:08+00:00 2026-06-17T05:40:08+00:00

bind text of same model inside a foreach loop but that text is not

  • 0

bind text of same model inside a foreach loop but that text is not a part of that array.

function SmsViewModel(data,id) {
    var self = this;

    // Editable data
    self.Sms = ko.observableArray(JSON.parse(data));
    self.Num = ko.observable('Send SMS');
    self.removeNumber = function(item){
    }
    self.myPostProcessingLogic = function(elements) {
 if ($(id).children().length === ko.toJS(self.Sms).length) {
        // Only now execute handler
    jq();
    }
}   


}

when i display data of sms it works fine but i am not able to display sel.Num in same foreach

<div class="modalbox_content" data-bind="foreach: {data: Sms,afterRender: myPostProcessingLogic}" id="KnockOutSmsData">

              <!-- ko if: FromAddress === '+18038004697' && TypeOfMassage === 'I' -->
                <div class="message_container" >

                  <div class="message_user_photo"><img src="images/user_pic.png" width="40" height="40"/></div>
                  <div class="message_cell_number"><span data-bind="text: FromAddress"></span></div>
                  <div class="recieved_message_container">
                    <div class="recieved_message_arrow"></div>
                    <div class="recieved_message_box">
                      <p><span data-bind="text: Body"></span></p>
                      <div class="forwd_message"><a href="#"><img src="images/frwd_msg.png"/></a></div>
                      <span data-bind="text: MsgDateTime"></span></div>

                  </div>

                </div>
                <!-- /ko -->
                <!-- close message container -->
                <!-- ko if: ToAddress === '+18038004697' && TypeOfMassage === 'S' -->
                <div class="message_container" >

                  <div class="sent_message_user_photo"><img src="images/user_pic.png" width="40" height="40"/></div>
                  <div class="sent_message_cell_number"><span data-bind="text: ToAddress"></div>
                  <div class="sent_message_container">
                    <div class="sent_message_arrow"></div>
                    <div class="sent_message_box">
                      <p><span data-bind="text: Body"></span></p>
                      <span data-bind="text: MsgDateTime"></span></div>
                  </div>

                </div>
                <!-- /ko -->
                <!-- close message container --> 

              </div>

i just want to compare

<!-- ko if: FromAddress === self.Num && TypeOfMassage === 'I' -->

this self.Num is the part of

self.Num = ko.observable('Send SMS');

and FromAddress is the part of

  self.Sms = ko.observableArray(JSON.parse(data));

thanx in advance

  • 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-17T05:40:09+00:00Added an answer on June 17, 2026 at 5:40 am

    I think you are looking for the $parent binding context variable with that you can access the “parent” object inside a foreach:

    <!-- ko if: FromAddress === $parent.Num() && TypeOfMassage === 'I' -->
    

    Note that you need write $parent.Num() (e.g. with ()) because Num is a ko.observable

    Here is a demo fiddle which is based roughly on your code.

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

Sidebar

Related Questions

I want to bind a string value to a text box but only if
I'm trying to bind a simple one-line string to a textbox's text property but
I'm doing a bind to document like below, $(document).bind('click',doThis); But i have a text
Normally we bind a textbox's Text property to a data-context's properties. The data-context can
Have same js code: $(#pr_list .c).bind({ click: function(event) { var m = $(this); var
I am trying to bind data from text files (and the names of those
Edit: I am trying to bind a single view model object that contains a
I am trying to bind data to a label when it is the same
I want to bind single viewModel's property with two html elements but its not
* *UPDATE I just realized that the date is not getting data-binded during post

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.