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

This sub-forum is for discussing all topics related to AppGini Helper JavaScript Library, provided by bizzworxx as a third-party AppGini plugin.
Post Reply
User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2020-11-09 07:38

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 1480 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 1480 times
Thanks already
Olaf

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

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

Post by jsetzer » 2020-11-09 07:45

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.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2020-11-09 08:14

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

User avatar
onoehring
AppGini Super Hero
AppGini Super Hero
Posts: 1156
Joined: 2019-05-21 22:42
Location: Germany
Contact:

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

Post by onoehring » 2020-11-09 08:19

Hi Jan,

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

Olaf

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

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

Post by jsetzer » 2020-11-09 08:43

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!
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

User avatar
jsetzer
AppGini Super Hero
AppGini Super Hero
Posts: 1807
Joined: 2018-07-06 06:03
Location: Kiel, Germany
Contact:

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

Post by jsetzer » 2020-11-09 08:44

@olaf, sorry, I have seen your (intermediate) post after writing my answer.
Kind regards,
<js />

My AppGini Blog:
https://appgini.bizzworxx.de/blog

You can help us helping you:
Please always put code fragments inside [code]...[/code] blocks for better readability

AppGini 24.10 Revision 1579 + all AppGini Helper tools

Post Reply