0

I combine primefaces with SVG and onclick. If I write just the first part "if($(window).width()>800){PF('dlg_p').show();}" there is no problem, but if I want to add another restriction don't work.

<svg width="200" height="210" onclick="if($(window).width()>600)&&($(window).height()>600){PF('dlg_s').show();}">

But the console gives me an error I can't solve:

Error Traced [line 313] The entity name must appear immediately after '&' in the entity reference.

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Arnau Guadall
  • 327
  • 1
  • 4
  • 17

2 Answers2

2

You have a syntax error in your code, see expanded here:

if(
    $(window).width()>600
) //<- this closes the if!
&&(
    $(window).height()>600
){PF('dlg_s').show();}

Instead you probably want:

if(
    ($(window).width()>600)
    &&
    ($(window).height()>600)
){PF('dlg_s').show();}

Edit: this is apparently only one half of the solution (as there are 2 mistakes in the code), see the question of which this is a duplicate: The entity name must immediately follow the '&' in the entity reference).

Community
  • 1
  • 1
doldt
  • 4,466
  • 3
  • 21
  • 36
  • Huh??? how can this be an accepted answer for this problem? – Kukeltje May 29 '15 at 09:43
  • Because there are two errors and each of you solved one of them. – Robert Longson May 29 '15 at 09:53
  • @Kukeltje your solution is indeed needed too (besides this), I just typed up this answer as this mistake stood out immediately for me. A +1 there and an attribution is all I can offer now. – doldt May 29 '15 at 11:43
  • :-). It is not about the +x attribution, and compliment that the other error stood out immediately (a little surprising that the other error with an explicit mentioning did not stand out ;-) ). I'll remove my answer since it is already market as a duplicate. – Kukeltje May 29 '15 at 13:25
1

As you wrote it here if statement ends after "600)". Check you braces. It should be like

onclick="if($(window).width()>600 && $(window).height()>600){PF('dlg_s').show();}">
bjaksic
  • 3,003
  • 1
  • 10
  • 12