- Screen name: Michał Ka
Michał Ka's Profile
3 Posts
2 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- 10-Feb-2014 07:32 AM
- Forum: Using jQuery Plugins
I'm trying to add a DateTimePicker plugin to a JQM app. Everything works when the HTML code is static in my app but when I pull the HTML via Ajax the plugin cease to initialize (I checked and all the plugin files loads to browser and there is no error in console, just nothing happens).
I'm sure this happens because plugin expects a HTML tag to hold on to ("input" in this case) which is not there onload - it shows when the Ajax fetches it from server file which takes a second.
The code is simple.
The plugin (this is pulled by Ajax into the HTML file):
- <input type="text" data-field="datetime" readonly>
- <div id="dateBox"></div> // space for plugin's calendar
Plugin init:
- $(document).on('pageshow', '#page-id-where-input-is-appended', function() {
- $("#dateBox").DateTimePicker();
- });
I suppose that solving this problem means to use appropriate JQM method when initializing. I used pageshow, and few different methods that works after the page DOM is ready - from pageinit to pagechange. With no success.
Any tips?
- 10-Dec-2013 04:45 AM
- Forum: jQuery Mobile
It seems I encountered an issue with setting sessionStorage by iPhone 5 Safari browser (latest IOS version) - in desktop browsers all works flawless.I have this simple code validating a login form with ajax:- <script>
- $(document).bind('pageinit', function() {
- $("button#submit").on('click', function() {
- if ($("#username").val() === "" || $("#password").val() === "") {
- $("div#response").html("Please enter both username and password");
- } else {
- $.ajax({
- type: 'POST',
- url: 'php/login.php',
- data: $("#loginForm :input").serializeArray(),
- success: function(data) {
- if (data === 'success') {
- window.location = 'start.html';
- } else {
- $("div#response").html(data);
- };
- }
- });
- }
- $("#loginForm").on('submit', function() {
- return false;
- });
- });
- });
- </script>
I'm trying to set the sessionStorage like this:- sessionStorage.password = $("#password").val();
but I don't know where to put this line without blocking execution of the further code. The obvious thing would be to put it inside the click event (to create session after a click) but putting it in the beginning blocks the ajax (I just get message from PHP file). When I put it lower outside the ajax or outside the click function or outside pageinit function, the sessionStorage is not set at all.What is wrong? Do I set the sessionStorage correctly? All seems to work fine on desktop browsers.- 04-Dec-2013 06:37 AM
- Forum: jQuery Mobile
Hi,I made a file which fetches data via PHP+MySQL and shows it on the page through $.ajax. The thing is that when I have data-transitions added to a link leading to that page the content from database doesn't load (it loads only after a page refresh). When I add data-ajax="false" to the link (which means I disable the transitions and default JQM ajax loading) everything works as new.How do I do it so I have transitions and my custom $.ajax loading at the same time?Maybe there is a way to activate my $.ajax code after the JQM ajax finishes loading the page?Any hints?- «Prev
- Next »
Moderate user : Michał Ka
© 2013 jQuery Foundation
Sponsored by and others.

