B4J Question [WebApp] [Solved] Trying to raise event of a div

AHilton

Active Member
Licensed User
Longtime User
The highlighted part of the JavaScript below is blocking the b4j_connect("/sales"). Why? When I take out the highlighted part, it connects and everything works.



JavaScript:
        <script>
        //connect to the web socket when the page is ready.
        $(document).ready(function() {
            var showHeaderAt = 150;

            var win = $(window),
                    body = $('body');

            // Show the fixed header only on larger screen devices
            if(win.width() > 600){
                // When we scroll more than 150px down, we set the
                // "fixed" class on the body element.

                win.on('scroll', function(e){

                    if(win.scrollTop() > showHeaderAt) {
                        body.addClass('fixed');
                    }
                    else {
                        body.removeClass('fixed');
                    }
                });
            }


            var input = document.getElementById("searcher");
            input.addEventListener("keyup", function(event) {
                if (event.keyCode === 13) {
                    event.preventDefault();
                    b4j_raiseEvent(input.id + "_Enter", {});
                }
            });

            var input2 = document.getElementById("card");
            input2.addEventListener("click", function() {
                b4j_raiseEvent(input2.id + "_Click", {});
            });

            b4j_connect("/sales");
        });
        </script>
 

AHilton

Active Member
Licensed User
Longtime User
Yes, finally found it. Thanks. Dumb mistake. I am dynamically creating that <div id="card"> once some of the other parts are selected by the user. So, of course, "card" doesn't exist when the page is first loaded giving a javascript error that I just didn't see. It's always that fourth-dimension!
 
Upvote 0
Top