JQuery Mobile Select menu opens as a dialog

I have a "pagebeforeshow" handler that clears the values ​​of my text fields and selects a menu.

$("#addSchedulePage").live("pagebeforeshow", function(event){
    $("#message", $("#addSchedulePage")).html("");//clear messagebox
    $("#message", $("#addSchedulePage")).hide();//hide messagebox
    $("#startDate", $("#addSchedulePage")).val("");
    $("#time", $("#addSchedulePage")).val("");

   var lstAppliance = $("#lstAppliance", $("#addSchedulePage"));
    var lstScheduleTaskType = $("#lstScheduleTaskType", $("#addSchedulePage"));
    lstAppliance[0].selectedIndex = 0;
    lstScheduleTaskType[0].selectedIndex = 0;

    $("#lstAppliance", $("#addSchedulePage")).selectmenu('refresh');
    $("#lstScheduleTaskType", $("#addSchedulePage")).selectmenu('refresh');

});

Here is the problem. When my menu selection options get too long, jqm automatically opens a new dialog box instead of dropping the list when I click on it and causing the event to fire again when I select the options from the selection menu. Is there any workaround or exit to stop the event from starting?

+3
source share
3 answers

Ok after I sat down and thought over the flow of my program, I managed to solve this problem by changing the way things were handled.

. schedulePage ( ) → addSchedulePage ( ) → .

schedulePage → addSchedulePage ('pagebeforeshow' )

→ addSchedulePage ('pagebeforeshow') - , , .

, , 'pagebeforeshow'. , , , "" . , , addSchedulePage, jquerymobile , DOM.

, -, .

0

, :

$("#addSchedulePage").live("pagebeforeshow", function(event){
    $("#message", this).html("").hide(); //clear and hide messagebox
    $("#startDate", this).val("");
    $("#time", this).val("");

    var lstAppliance = $("#lstAppliance", this);
    var lstScheduleTaskType = $("#lstScheduleTaskType", this);
    lstAppliance[0].selectedIndex = 0;
    lstScheduleTaskType[0].selectedIndex = 0;

    lstAppliance.selectmenu('refresh');
    lstScheduleTaskType.selectmenu('refresh');
});

:

  • this, $("#addSchedulePage").
  • clained .html() .hide()
  • lstAppliance lstScheduleTaskType
+3

I had the same problem and it was resolved. This may solve you:

fooobar.com/questions/1820247 / ...

0
source

All Articles