Domanda

I have the following .js file for my project. This is running in a regular browser, using jquery 1.9.x and jquerymobile 1.3.1. The init function below appears to be running when the page loads and the UI is not updated. Though... I can copy the function into the console and run it, and the UI updates as it is supposed to, so this in not a case of incorrect file paths, or incorrect ids for the UI elements, but I suspect timing. I am also NOT using cordova or phone gap in this instance.

So, my question is, why is the UI not updating when the $(document).bind('pageinit', ...) function is called? If I put a breakpoint in the init method, it is getting called when the page loads. Any suggestions on using a different event or approach?

var simulator = simulator || {};

(function (feedback, $, undefined) { 'use-strict';
    feedback.init = function () {
        $.get('feedback-config.xml', function (data) {
            $('#feedback-to').val($(data).find('email').text());
            $('#feedback-subject').val($(data).find('emailSubject').text());
            $('#feedback-display').html($(data).find('message').text());
            $('#feedback-form').attr('action', $(data).find('serverurl').text()).ajaxForm({success: function () {
                alert("Thank you for your feedback!");
            }, error: function () {
                alert("We're having difficulties sending your feedback, sorry for the inconvenience.");
            }});
        });
    };
}(simulator.feedback = simulator.feedback || {}, jQuery));

$(document).bind('pageinit', function () { 'use strict';
    simulator.feedback.init;
});

Thanks in advance.

È stato utile?

Soluzione

Found it, simple mistake... In the 'pageinit' function I am calling simulator.feedback.init; instead of simulator.feedback.init(); Not sure why JSLint didn't pick that up initially, but it pointed it out when I tried again later. Thanks.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top