Page 1 of 1

bug? AG 5.91 -> .setTitle can be done twice?

Posted: 2020-11-09 07:38
by onoehring
Hi,

using AG 5.91, I notice, that in a custom page the .setTitle seems to actually set the icon twice.
I am including header-extras and footer-extras in my custom page and both have this code:

Code in header-extras.php

Code: Select all

<script>
  var url="/myTtitleImage.png"
  new AppGiniCommon()
  .setTitle("<b>myTtitle</b>")
  .setImage(url);	
</script>
Code in footer-extras.php

Code: Select all

<script>
  $(function() {
    var url = "/myTtitleImage.png"
    new AppGiniCommon()
    .setTitle("<b>myTtitle</b>")
    .setImage(url);
  });
</script>
Some other related questions:
a) which one is the better code that you would suggest?
b) where would you suggest putting the code? header or footer?

This fist images shows a regular AG page:
image_regular.png
image_regular.png (2.18 KiB) Viewed 3467 times
This second images shows the creation process while my custom page is loading and the images are being placed:
image_custom.gif
image_custom.gif (11.41 KiB) Viewed 3467 times
Thanks already
Olaf

Re: bug? AG 5.91 -> .setTitle can be done twice?

Posted: 2020-11-09 07:45
by jsetzer
Good morning,

short question, because I'm not sure if I got it:

Did you put the identical code twice, in header-extras AND in footer-extras?

Or does it mean:
You have tried to put it in header (only) and it gave duplicates. Then you have tried to put it in footer (only), and it also gave duplicates.

Sorry, I did not completely understand the settings.

Re: bug? AG 5.91 -> .setTitle can be done twice?

Posted: 2020-11-09 08:14
by onoehring
Hi Jan,

actually at this time I have put it in header-extras AND (a second time) in footer-extras.
I am not even sure why.... and I am willing to remove one ... which?

Btw: On https://appgini.bizzworxx.de/products/j ... tail-view/ you mention a new way to initiate AGHelper.
old: var dv = new AppGiniDetailView();
new: var dv = AppGiniHelper.DV;
Do I need to adjust new AppGiniCommon() somehow as well?

Olaf

Re: bug? AG 5.91 -> .setTitle can be done twice?

Posted: 2020-11-09 08:19
by onoehring
Hi Jan,

removed it from header-extras (left in footer-extras) - seems to work now.
Sorry for bothering.

Olaf

Re: bug? AG 5.91 -> .setTitle can be done twice?

Posted: 2020-11-09 08:43
by jsetzer
I have just double checked it:
If you call .setImage() function multiple times, the given image will be prepended on each call.

Perhaps I should have named that function "addImage" in the past to avoid irritation. I consider changing the code in one of the next versions. Then .setImage() should replace image, if exists, instead of prepending.

Recommendation for setImage

Code: Select all

// file: hooks/header-extras.php
AppGiniHelper.common
  .setTitle("your<b>TITLE</b>")
  .setImage("table.gif"); // <-- valid image url
Recommendation for setIcon

Code: Select all

// file: hooks/header-extras.php
AppGiniHelper.common
  .setTitle("your<b>TITLE</b>")
  .setIcon("cog");
List of available (Glyph-) icons:
https://glyphicons.bootstrapcheatsheets.com/

@all:

General recommendations

Please avoid multiple initializations of identical objects like AppGiniCommon. If you already have initialized AppGiniCommon in header-extras.php and assigned that object to a variable named common, there is no need to initialize another instance of AppGiniCommon and assign it to the already existing variable. Usually, this is not critical but not best practice.

For that reason of multiple initializations giving side-effects in few scenarios*, please also note there are new, recommended, singleton ways for initializing especially AppGiniDetailView but also AppGiniTableView and AppGiniCommon:

https://appgini.bizzworxx.de/products/j ... mentation/
  • Detail View

    Code: Select all

    var dv = AppGiniHelper.DV;
    
  • Table View

    Code: Select all

    jQuery(function(){
      var tv = AppGiniHelper.TV;
    });
    
  • Common

    Code: Select all

    var common = AppGiniHelper.common;
    
* Reason: due to multiple initializations of AppGiniDetailView by very few developers, there were some side effects especially in DV. So we have decided to refactor this and add singleton functions to avoid such problems in DV. There were no bug reports concerning TV and Common, but to make this more consistent we have also introduced singletons for TV and Common. The old way will still work for backward compatibility. I recommend getting used to using the new syntax. At least if you have problems in Detail View, please consider using the recommended new syntax and testing again before posting a bug report. Thank you!

Re: bug? AG 5.91 -> .setTitle can be done twice?

Posted: 2020-11-09 08:44
by jsetzer
@olaf, sorry, I have seen your (intermediate) post after writing my answer.