Event firing on button click and back button click

4 posts, 0 answers
  1. Chuck
    Chuck avatar
    4 posts
    Member since:
    Jul 2010

    Posted 06 Mar 2012 Link to this post

    I am finding that an event I have defined for a button is not only firing when the button is clicked, but also when the back button is clicked.  I have the following code:
    <div class="back-button-show" data-role="view" data-layout="app" data-show="getVendorDetails" data-title="" id="vendor-details">
            <div id="vendor-detail-div">
                <div id="vendor-detail-name" data-bind="text: name"></div>
                <div id="vendor-detail-tagline" data-bind="text: tag_line"></div>
                <div id="vendor-detail-url" data-bind="text: url"></div>
                <div id="vendor-detail-about" data-bind="text: about"></div>
                <a class="button-left" data-role="button" data-click="addToFavoritesClick">Add to Favorites</a>
                <a class="button-right" data-role="button" data-click="addToContacts">Add to Contacts</a>
            </div>
    </div>
           
     <div data-role="layout" data-id="app" data-show="layoutShowInit">
            <header data-role="header">
                <div data-role="navbar">
                    <a class="nav-button" data-role="backbutton" data-align="left">Back</a>
                    <span data-role="view-title">Demo Conference</span>
                </div>
            </header>
             
            <footer data-role="footer">
                <div data-role="tabstrip">
                    <a href="#main-page" data-icon="info">Info</a>
                    <a href="#vendors" data-icon="organize">Vendors</a>
                    <a href="#favorite-vendors" data-icon="favorites">Saved Vendors</a>
                </div>
            </footer>
     </div>
     
    <script>
    var addToFavoritesClick = function(e) {
       alert("This is a test");           
    };
    </script>

    What I have found, is if I click on the Add to Favorites button I get the alert like I expect.  Then if I click the back button, I get the alert again a second time.  However if I view the page and do no click the Add to Favorites button and click the back button I do not get the alert.  Any help would be greatly appreciated.
  2. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 07 Mar 2012 Link to this post

    Hello,

    I failed to reproduce the problem in this jsFiddle. I clicked on the foo button, clicked on the go to bar button, then used the browser back button to go back. Using Safari 5.1.3 / Mac. 

    What am I missing? 

    Greetings,
    Petyo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Kendo UI is VS 2017 Ready
  4. Chuck
    Chuck avatar
    4 posts
    Member since:
    Jul 2010

    Posted 07 Mar 2012 Link to this post

    Interesting in that is does not do it when using Kendo Mobile in the browser.  Perhaps it is a bug with PhoneGap.  The entire project is a PhoneGap project.  I will post my source later today to github.
  5. Petyo
    Admin
    Petyo avatar
    2439 posts

    Posted 08 Mar 2012 Link to this post

    Many thanks for your collaboration. Please let us know if you we can help any further with the problem.


    Petyo
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
Kendo UI is VS 2017 Ready