0

Sorry if wrong format or dumb question, I'm new to this. I use knockout js and normally use it to find a image with an index and display it, however, I'm wondering if it is possible to ensure it is the last image that gets used regardless of index number, below is an example of the code I currently use.

  <div style="position: absolute; right: 0px; bottom: 0px">
    <!-- ko foreach: PropertyDetails().Images() -->
    <!-- ko if: DocumentSubType().SystemName() === "Photo" -->
    <!-- ko if: $index() === 7 -->
    <div
      data-bind="attr:{id: 'picture-' + Id() }, widget: {
                kind: 'ImageManipulator',
                config: {
                    width: '546px',
                    height: '380px',
                    imageUrl: Url().indexOf('http://www.example.com/estate-agent-software/ImageResizeHandler.do') == -1 ? Url() + '?width=NaN' : Url() + '&width=NaN'
                },
                identification: {
                    Id: 'property-image-' + Id()
                }}"
    ></div>
    <!--/ko-->
    <!--/ko-->
    <!--/ko-->
  </div>
1
  • I would extend your image object and add there a field called isLast. UI shouldn't know and care about indexes and images count :) Commented Sep 29, 2023 at 5:36

1 Answer 1

1

changing out the last ko if: to

 <!-- ko if: $index() === $parent.PropertyDetails().Images().length - 1 -->

did the trick, just in-case anyone else comes across this question :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.