DEVHIDE
  • Home (current)
  • About
  • Contact
  • Cookie
  • Home (current)
  • About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy
  • TOS
Login Or Sign up

RIVETS.JS - What's the correct syntax in order to resolve a placeholder in html image src?

2.3k Views Asked by Cisco At 02 January 2014 at 12:33 2025-11-21T05:07:46.449000

I've created the following page:

<div id="mypage" data-role="page" data-theme="w">
<div id="header" data-role="header" class="ui-noboxshadow ui-header-fixed" data-position="fixed">

</div>
<div data-role="content">       
    <p class="detail-row" style="margin-top: 1em;"><span class="detail-value">{mypage.currentDate}</span></p>
    <p class="detail-row" style="margin-top: 1em;"><span class="detail-value"><img id="myimage_id" src="{mypage.myimage}" /></span></p>
    <p class="detail-row" style="margin-top: 1em;"><span class="detail-value">{mypage.mytitle}</span></p>
    <p class="detail-row"><span class="detail-value">{mypage.mydescription}</span></p>
</div>
<div id="footer" data-role="footer" data-position="fixed" data-theme="g" class="ui-noboxshadow" data-tap-toggle="false">
</div>

It works well (mypage.currentDate,mypage.mytitle, mypage.mydescription placeholders are resolved correctly) except for mypage.image placeholder: it is not resolved (I obtain this url: /%7Bmypage.myimage%7D)

Debugging javascript I saw that mypage.myimage contains the correct value in the model so what's the current syntax in order to resolved my path in img src attribute?

EXAMPLE:

If I try to write:

{mypage.myimage}

it is correctly translated in

/contextroot/images/image.jpg

BUT

if I write it is transformed in <img src="/%7Bmypage.myimage%7D" />

It is not translated, the variable is not resolved!

javascript html jquery-mobile rivets.js
Original Q&A
1

There are 1 best solutions below

0
Elliot Elliot On 07 January 2014 at 16:57 BEST ANSWER

You need to write a binder for the src attribute:

rivets.binders.src = function(el, value) {
  el.src = value;
};

Then to use it you write:

<img rv-src="mypage.myimage" />

UDPATE: Looking at the docs I don't think you even need to define the binder. It should default to setting the attribute name after rv-

Related Questions in JAVASCRIPT

  • Angular Show All When No Filter Is Supplied
  • Why does a function show up as not defined
  • I count the time the user takes to solve my quiz using Javascript but I want the same time displayed on another page
  • Set "More" "Less" font size
  • Using pagination on a table in AngularJS
  • How to sort these using Javascript or Jquery Most effectively
  • how to fill out the table with next values in array with one button
  • State with different subviews
  • Ajax jQuery firing multiple time display event for the same result
  • Getting and passing MVC Model data to AngularJS controller
  • Disable variable in eval
  • javascript nested loops waiting for user input
  • .hover() seems to overwrite .click()
  • How to sort a multi-dimensional array by the second array in descending order?
  • How do I find the fonts that are not loading in a CORS situation ( MoovWeb )?

Related Questions in HTML

  • Delay in loading Html Page(WebView) from assets folder in real android device
  • Why does a function show up as not defined
  • CSS Class is not applying to element (border width,color,and style attributes)
  • How to sort these using Javascript or Jquery Most effectively
  • how to fill out the table with next values in array with one button
  • Automatically closing tags in form input?
  • Positioning child at bottom of parent with scroll
  • Remove added set of rows
  • Website zoomed out on Android default browser
  • Twitter Bootstrap horizontal form elements on a line
  • http://sigmajs.org/ les mis tutorial - why are my canvases 0 height?
  • My navbar is not expanding after collapse
  • when a checkbox is checked how to display a different hidden element using javascript
  • Gaps Vertically Using Dividers
  • Svg containers not positioning properly

Related Questions in JQUERY-MOBILE

  • Get selected columns for a columntoggle table
  • jQuery mobile - generating html dynamically not working with iframe
  • jQuery mobile Multiselect doesn't update selected attribute
  • Exit windows app confirmation button not working
  • jquery mobile swipe stops if i swipe right on the first page and and left on the last page
  • Jquery Mobile: Horizontal Buttons, fill container
  • Cordova camera plugin not working in Android mobile but working in emulator
  • how to parse a xml file using jquery and phonegap?
  • pass input value with jquery does not work
  • Photoswipe Custom Button
  • why the input box is not disable while checking the check box?
  • Display Mobile Compatible when it's on mobile
  • Xml audio list player not working on the mobile and autoplay is not working
  • Dygraph not shown on collapsed jQuery mobile collapsible widget
  • Jquery slideToggle and hover issues

Related Questions in RIVETS.JS

  • Add components dynamically in rivets.js not working
  • How to print an array in rivets.js
  • RIVETS.JS - What's the correct syntax in order to resolve a placeholder in html image src?
  • Rivets.js event handlers with custom arguments
  • Rivets.js binding default javascript adapter not updating always
  • rivets.js each-* not displaying
  • Rivets stops working with some libraries after Sightglass was introduced
  • Simple Example using Backbone.js and Rivets.js
  • Iterate over a collection of Backbone.js models using Rivets.js?
  • How to bind deeper than one level with rivets.js
  • How to configure Rivetsjs components
  • refreshing rivets.js rv-show bound to a value via a custom formatter via another value
  • Rivets.js iterating over collection
  • Make simple databinding with rivetsjs
  • Accessing array index with Rivets.js

Trending Questions

  • UIImageView Frame Doesn't Reflect Constraints
  • Is it possible to use adb commands to click on a view by finding its ID?
  • How to create a new web character symbol recognizable by html/javascript?
  • Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
  • Heap Gives Page Fault
  • Connect ffmpeg to Visual Studio 2008
  • Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
  • How to avoid default initialization of objects in std::vector?
  • second argument of the command line arguments in a format other than char** argv or char* argv[]
  • How to improve efficiency of algorithm which generates next lexicographic permutation?
  • Navigating to the another actvity app getting crash in android
  • How to read the particular message format in android and store in sqlite database?
  • Resetting inventory status after order is cancelled
  • Efficiently compute powers of X in SSE/AVX
  • Insert into an external database using ajax and php : POST 500 (Internal Server Error)

Popular # Hahtags

javascript python java c# php android html jquery c++ css ios sql mysql r reactjs

Popular Questions

  • How do I undo the most recent local commits in Git?
  • How can I remove a specific item from an array in JavaScript?
  • How do I delete a Git branch locally and remotely?
  • Find all files containing a specific text (string) on Linux?
  • How do I revert a Git repository to a previous commit?
  • How do I create an HTML button that acts like a link?
  • How do I check out a remote Git branch?
  • How do I force "git pull" to overwrite local files?
  • How do I list all files of a directory?
  • How to check whether a string contains a substring in JavaScript?
  • How do I redirect to another webpage?
  • How can I iterate over rows in a Pandas DataFrame?
  • How do I convert a String to an int in Java?
  • Does Python have a string 'contains' substring method?
  • How do I check if a string contains a specific word?
.

Copyright © 2021 Jogjafile Inc.

  • Disclaimer
  • Privacy
  • TOS
  • Homegardensmart
  • Math
  • Aftereffectstemplates