Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // =========================
- // Application bootstrapper
- // =========================
- // =========================
- // Config, preferably loaded from the back-end
- // =========================
- var config = {
- title: 'forum',
- version: '0.1.0',
- // Other config options, server address etc.
- misc: {
- floatingMenu: true
- }
- };
- // =========================
- // User account, also loaded from the back-end
- // after the login authentication
- // =========================
- var user = {};
- // =========================
- // Initial function
- // =========================
- $(function(){
- // Here the app launches
- // Configure menu
- navigationCtrl.setNavigationFloating( config.misc.floatingMenu );
- utils.loadTemplate(
- 'tpl/testTemplate.html',
- {},
- function(template){
- // After the template is loaded on to the page,
- // select the 'submit' button from it via jQuery.
- // The button in the template has a class 'submit-button'
- // Also, select the fields, so that you can read the
- // values from them.
- var $submitButton = $('.submit-button'),
- $formLogin = $('.input-fields > #user-name'),
- $formPassword = $('.input-fields > #user-password'),
- $formEmail = $('.input-fields > #user-email');
- // Now add an event to the button
- $submitButton.on('click',function(eventData){
- // On click, the button sends data to the back-end server.
- // jQuery.val() Reference - http://api.jquery.com/val/
- utils.sendData('http://backend.com/user',{
- login: $formLogin.val(),
- password: $formPassword.val(),
- email: $formEmail.val()
- }, function(response){
- // When you get the responseh, it can be a JSON,
- // check if everything is ok and react.
- if( response.success === true ){
- // Show a happy message to the user, maybe load another template
- alert('Registered!');
- } else {
- // Show some error to the user
- alert('Error - back-end is fucked');
- }
- });
- });
- }
- );
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement