Announcement

Collapse
No announcement yet.

Event listener javascript strange problem

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Event listener javascript strange problem

    Hi all.
    I have a very strange problem.
    I think it's not a bridge problem, but rather some javascript peculiarity.

    I'm writing a dashboard using the bootstrap sb-admin template, Bridge.NET 17.0.0.0 and the HTML5 package because I have a project constraint of this.
    I need to manage the click on an object.
    If I place the object in the sidebar of the template, the click is managed and works.
    If I move the same code to the main division of the template, the listener is created, but not works.

    I don't get errors during bridge compilation.
    Javascript doesn't go wrong on the browser at runtime.

    The code to create the object in bridge is this.

    HTMLAnchorElement anchordashboard = new HTMLAnchorElement
                    {
                        ClassName = "nav-link",
                        Href = "#",
                        InnerHTML = "<i class=\"fas fa-fw fa-tachometer-alt\"></i>"
                    };
                    HTMLSpanElement spandashboard = new HTMLSpanElement
                    {
                        InnerHTML = " Dashboard",
                        OnClick = (ev) => { Window.Alert("Here"); }
                    };
                    anchordashboard.AppendChild(spandashboard);
                    mainpanel.AppendChild(anchordashboard);
    When it's compiled, the event management code is always created.

    The two positions in the template are different only for CSS classes and I didn't find any interference from other javascript code.

    If the object is in the sidebar division the browser recognizes the event, while if it's in the main panel, even from dev tools you see that there is no event listener.

    I don't even know where to look for the problem..
    Does anyone have any idea where I can look for the problem?

    This is the generated javascript code from bridge.net
    Click image for larger version

Name:	Js_Main.PNG
Views:	1
Size:	59.3 KB
ID:	5692

    Click image for larger version

Name:	Js_Sidebar.PNG
Views:	1
Size:	36.9 KB
ID:	5691

    Click image for larger version

Name:	Js_Dashboard.PNG
Views:	1
Size:	26.8 KB
ID:	5689

    And this is the code from dev tools of browser
    Click image for larger version

Name:	HTML_Code.png
Views:	1
Size:	47.6 KB
ID:	5690

    #2
    Hello @Noos80!

    The way you are providing your issue is not likely to get much help, as the code is from printscreen. In a shallow look at the code, I don't really see anything obviously wrong with it, but I don't see anything that MUST have worked either.

    I have some suggestions for you to improve the odds on getting help on this issue, or being able to solve it by yourself:
    1. reproducing it on deck. That's the definitive way to ensure others will be able to reproduce your issue, and as how you described your scenario and the bit of copy-paste-able code you provided, it really looks like it would be feasible to draw your scenario there.
    2. to find yourself directions on how to determine the issue, you can use the browser's development tools (generally by hitting f12 key while with the page open). Chances are you already know very well of this tool, but maybe it comes handy; you can just add a breakpoint (or use google chrome's `debugger` javascript command) and check call stack from when it triggers, then looking after oddities when it moves around.
    3. simplifying (and that's perhaps a very important part you'd have to undergo if you are going for a deck example), may allow you to further isolate what exactly prevents the event from being triggered.
    4. you can try to manually make (from raw javascript) what you want (that is, a hand-crafted copy of the "object" within the "sidebar" correctly triggering the events), so it serves as a base to understand what's amiss in Bridge.

    While the Bridge.Html5 has been moved into an "archived" state, it shouldn't mean it will "develop issues" over time, so I believe it should work and you should be able to find the solution for this. And if you do find the issue is within the Bridge.Html5 library, you are more than welcome to help with the fix thru a pull request on its repository. We still package and publish new Bridge.Html5 versions every minor Bridge release.

    Well, I hope this helps!

    Comment

    Working...
    X