This is a migrated thread and some comments may be shown as answers.

Event firing on button click and back button click

3 Answers 295 Views
Button (Mobile)
This is a migrated thread and some comments may be shown as answers.
Chuck
Top achievements
Rank 1
Chuck asked on 07 Mar 2012, 04:10 AM
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.

3 Answers, 1 is accepted

Sort by
0
Petyo
Telerik team
answered on 07 Mar 2012, 09:11 AM
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!
0
Chuck
Top achievements
Rank 1
answered on 07 Mar 2012, 11:46 AM
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.
0
Petyo
Telerik team
answered on 08 Mar 2012, 09:48 AM
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!
Tags
Button (Mobile)
Asked by
Chuck
Top achievements
Rank 1
Answers by
Petyo
Telerik team
Chuck
Top achievements
Rank 1
Share this question
or