how to pass data-bind value into my <href> tag

I'm getting data-bind value from sharepoint list. I want to pass the value to the hyperlink, how do I do that.

My html code looks like this, here I'm looping to bind the rows that I got from sharepoint list. I'm trying to pass field value 'ID' in the hyperlink as you can see below but not sure how I can pass data-bind value inside the hyper tag.... I want something like ="/devsite/Lists/test/DispForm.aspx?ID=" data-bind value here><


<table>
  <tbody data-bind='foreach: $root.test.Rows'>
  <hr>
  <tr>
  <tr>
    <td><b>
      <li><a href="/devsite/Lists/test/DispForm.aspx?ID="><font size = 3>
        <div data-bind='text: Title'></div>
        </font></a></li>
      </b></td>
  </tr>
  <tr>
    <td>
</TABLE>

Open in new window

bujjigaduAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
Hi,
could you please explain:
- which SharePoint version and edition?
- How do you get the list data?
- Where will this HTML code run: inside SharePoint / outside in an ASP.NET app ?
- Which Javascript framework do you use for data-binding?

Thanks
Rainer

And a general tip: you should increase the points of your questions - just to attract more people as your questions are very time-consuming to answer and not that many experts will invest their precious time for only 150 points.
0
bujjigaduAuthor Commented:
I'm using SharePoint 2013. I'm using knockout js to get the details from the sharepoint list.

Once I got the results I'm doing for-each loop in html to do data-bind values. I want to pass one of the data-bind value inside <href> tag..

HTML code is part of the script that I use in cotent editor webpart to render the code snippet.
0
Rainer JeschorCommented:
Hi,
OK, that makes sense.
Assuming you have a field "ID" in your knockout model for each row (containing the SharePoint list item id), you have either the option to generate the whole url already as an observable / function in your model:
function AppViewModel(data) {
            this.Url = ko.observable("/devsite/Lists/test/DispForm.aspx?ID="+data.ID);
        }

Open in new window

and then use this in your HTML:
<tr>
    <td><b>
      <li><a data-bind="attr: { href:Url}, text:Title"></a></li>
      </b></td>
  </tr>

Open in new window


OR
directly this in your HTML
<a data-bind="attr: { href:'/devsite/Lists/test/DispForm.aspx?ID=' + ID()}, text:Title"></a>

Open in new window


For a really tested and working solution, your complete HTML / Javascript code would be necessary - as your above provided fragment is not valid HTML (missing end tags, not allowed HR tag inside of tablebody ...) and of course a short description of your SharePoint list (columns and data types).
HTH
Rainer
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bujjigaduAuthor Commented:
ok let me try and get back on this...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Development

From novice to tech pro — start learning today.