LitBe
LitBe

Reputation: 183

jQuery Mobile more buttons for one function

I use an external header for a Multi-Page Template JQM 1.4

$('#pageprostoriheader').load('header.html', function () {
  $.mobile.pageContainer.pagecontainer("getActivePage").enhanceWithin();
});

$('#pagetestheader').load('header.html', function () {
  $.mobile.pageContainer.pagecontainer("getActivePage").enhanceWithin();
});

In the header I have a button with ID gumbiskanje, that opens a popup dialog.

$(document).on('click', '#gumbiskanje', function(e){
  var niz = $('#niziskanje').val();
  prikaziiskanje(niz);
  window.location.href = "#pageiskanje";
});

when i had only one page worked all fine, but now that i have multiple page. It only works on the first page in html, but on other pages it doesn't start the dialog.

Upvotes: 1

Views: 122

Answers (1)

Omar
Omar

Reputation: 31732

Update

Popup div should be either place internally as a child of page div, or externally outside page div.

If placed externally, you need to call the below function in order to enhance/create it. Then you will be able to call it from any page.

$(function () {
  $("[data-role=popup]").popup();
});

To call it

$(document).on("click", "#gumbiskanje", function () {
  $("#popupLogin").popup("open");
});

Demo


If you have the same popup in each page with the same id, you need to call it from within the active page too.

$(document).on("click", "#gumbiskanje", function () {
  var active = $.mobile.pageContainer.pagecontainer("getActivePage");
  $(active).find("#popupLogin").popup("open");
});

Demo

Upvotes: 1

Related Questions