Jqm is not a function

房东的猫 提交于 2019-12-12 03:08:48

问题


I'm having some trouble with Jquery and JqModal, and I hope you are able to help, since I've been struggling for hours..

Having a single button element with an onclick action running my method "test" (shown below):

$('#picture_form').jqm({ajax: '/test.php'});

$('#picture_form').jqmShow();

This will load the ajax content of test.php into my div element picture_form, shown using JqModal as its supposed to! Though when I close this window, and re-clicks the button I'm getting the error:

$("#picture_form").jqm is not a function.

As a solution I've tried to use the JqModal trigger function, and this leaves me able to open and close the JqModal windows as many times as I want to. Sadly I can only call the 'trigger' using test environment, in my production code I have to open the JqModal window using a function..

Does anyone have a clue why this 'bug' appears when calling the opening when using a function?

Thanks in advance


回答1:


If memory serves, you are only supposed to call the initializing jqm method once. Try initializing the modal in a document.ready event, then in your onclick you just need to call the jqmShow function. If this still doesn't work, could you post a bit more of the surrounding code? Good luck!




回答2:


This should solve it. Add it at the point where you want to show it:

$('#ex2').jqm({ajax: action,target: 'div.jq_content', trigger: false, modal:true }).jqmShow();


来源:https://stackoverflow.com/questions/2960945/jqm-is-not-a-function

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!