Get ready for BLACK FRIDAY shopping starting in

HTML5 Data Bindings Formatter Support Product Page

Using conditionals inside function call

Asked 08 Jul 2016 11:09:50
1
has this question
08 Jul 2016 11:09:50 Hans Haverlach posted:
Hi, in my code I have a function call from onClick with two parameters:

onClick="myFunction('{{gb_gebid.min( 1 ).then( "{{gb_gebid}}", 'none' )}}','name')

above does not work.
What I am trying to do is: if the first parameter: {{gb_gebid}} is greater then NULL (or is NOT empty) then show value, otherwise show value: 'none'

Is this possible with data bindings formater

Replies

Replied 08 Jul 2016 11:51:16
08 Jul 2016 11:51:16 Teodor Kuduschiev replied:
Hello Hans,
Can you paste your function code also?
Replied 08 Jul 2016 12:00:37
08 Jul 2016 12:00:37 Teodor Kuduschiev replied:
Actually, i've just tested with a simple alert. Your code should look like:


onClick="myFunction('{{gb_gebid > 0.then( gb_gebid, "none" )}}','name')

Replied 08 Jul 2016 12:50:26
08 Jul 2016 12:50:26 Hans Haverlach replied:
Thank you,but it does not yet work:
In code expector view I see this:


<div class="endo_playmusic float-left" onclick="getmoving('gb_gebid > 0.then( {{gb_gebid, "none")}}','Ad Colen');" title="Toon extra afbeeldingen">
          
          [img]template/web/images/sm/afbeeldingen.png"> </div>

My function code:
function getmoving(endid,endnaam) {
var fotoframe = $(".myClass");
$(fotoframe).html("");
$(".myClass").animate({ padding:24, position:'absolute',display:'block', overflow:'hidden', left:0, right:0, marginLeft:'auto', marginRight:'auto'}, {duration:2000, easing:"easeOutStrong"});
 
var fotourl = "extensies/rotator/sjablonen/rotator_files.php?end_id="+endid+"&endnaam="+endnaam;
var furl = encodeURI(fotourl);
 setTimeout(function() {
$(".myClass").load(furl);
}, 700); // <-- time in milliseconds

}
Replied 08 Jul 2016 12:56:09
08 Jul 2016 12:56:09 Teodor Kuduschiev replied:
The onclick code you pasted is wrong. Just copy and paste the one i sent you .... in code view:

onClick="getmoving('{{gb_gebid > 0.then( gb_gebid, &quot;none&quot; )}}','Ad Colen')"
Replied 08 Jul 2016 14:42:08
08 Jul 2016 14:42:08 Hans Haverlach replied:
Thank you, we are getting there... almost
The {{gb_gebid}} is most of the records is 0;

Now when i use the code and check the code in the broser codeview I see this:

<div class="endo_playmusic float-left" onclick="getmoving('false','Klaas  Vaakje');" title="Toon extra afbeeldingen">
          
          <img src="template/web/images/sm/afbeeldingen.png"> </div>


Instead of false I want to see: none
Replied 08 Jul 2016 14:43:21
08 Jul 2016 14:43:21 Teodor Kuduschiev replied:
What do you mean by: The {{gb_gebid}} is most of the records is 0; ?
I am not sure i understand you. Can i see a link to your page?
Replied 08 Jul 2016 19:24:22
08 Jul 2016 19:24:22 Hans Haverlach replied:
That was a typo.
I meant that the value of field {{gb_gebid}} in most records is 0 (zero). In the conditional code that should result in a respons: 'none'. Right now it gives the response: 'false'

And if the value of the field {{gb_gebid}} is > 0 then it should give its actual value.
I cannot send you a pagelink, site is in development and protected.
But thank you for all your suggestions so far!
Replied 11 Jul 2016 07:58:36
11 Jul 2016 07:58:36 Teodor Kuduschiev replied:
The code i provided must be doing exactly this. I need to see your page to be able to inspect what is wrong.

Reply to this topic