0 Replies Latest reply on May 21, 2009 7:33 AM by alexbariv

    How should be the diagram of the application with Air+JS ?

    alexbariv

      Greetings Everybody (again).

       

      The thing is that I'm trying to migrate my AJAX+PHP Application to AIR, and everything was going really smooth. But, then start the pain with just some javascript function calls.

       

      Let me explain: In AJAX i have three pages for a Login procedure, one index.html that holds the diagram of the interface (like top, menu, main, bottom all in CSS), the login_form.html that holds only the form with a user/pass fields and the main_app.html, that appears only if the login in form.html its successful.

       

      So, in index.html i have a function like this:

       

      function updateView(urlHref) {

       

          var loader  = '<div id="loader" style=\"margin-left:25px;margin-top:25px;float:left\">'+
                            '<img src="images/ajax-loader.gif"></div>';

       

          form        = typeof(form) != 'undefined' ? form : '';
         
          $.ajax({
              type       : 'get',
              url        : urlHref,
              dataType   : 'html',
              cache      : false,
              beforeSend : function () {
                  $('#top').append(loader);
              },
              success    : function (html) {
                 
                  if ($('#loader').fadeOut('slow'))
                      $('#loader').remove();

       

                  $('#principal').html(html);
                     
              }
          });
      }

       

      This function loads a page in one div called #principal. So, when index is executed has a php code that checks if a session is active. If it makes a <body onLoad="updateView('main_app.html')">, if not calls the form <body onLoad="updateView('form.html')">.

       

      In AIR the call and the loaded page works perfect, but if form.html tryies to call a javascript function, just doesn't work.

       

      All the javascript functions and everything are located in index.html. In the browser this works perfect, i can load any page inside a div and this page can call a javascript funcition declared in index.html without problems.

       

      Maybe I'm doing a wrong approach to the design of the interface, but in AJAX+PHP all the views, forms, are separated in html pages, to keep the thing organized.

       

      I just keep reading, docs, cookbooks and everything but all the samples that i see are ONE form, or ONE view per application.

       

      So, how can I make this work, or wich are the correct aproach ?

       

      Thank you very much in advance.