android - Jquery Mobile Dynamic Component Creation -


I will create JQ widgets / components on the fly. So that I create a custom function to make it Please check the code given below:

  & lt ;! DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Title & gt; JQM 1.4.2 & lt; / Title & gt; & Lt; Meta name = "viewport" content = "width = device-width, initial-scale = 1" & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Link rel = "stylesheet" href = "http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.css" /> & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div data-role = "page" id = "one" & gt; & Lt; Div data-role = "content" & gt; & Lt; Div id = "checkboxComponent" & gt; & Lt; / Div & gt; & Lt; Div id = "radioComponent" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Script src = "http://code.jquery.com/jquery-1.9.1.min.js" & gt; & Lt; / Script & gt; & Lt; Script src = "http://code.jquery.com/mobile/1.4.2/jquery.mobile-1.4.2.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; Var checkbox Array = ["car", "bike", "land"]; Var radio buttonArere = ["car", "bike", "land", "house", "farm"]; Function createComponent (type, element, data) {$ ("#" + element) .html ('div data role = "controlgroup" class = "controlGruopDiv"> ') ; ('& Lt; input type =' '+ + type +' "name =" '+ + "" id = "" + + + + + + + + + + "+" + + "+ g +; + + + Data for [i] + '& lt; / label & gt;' '+ + + +' '& gt; & lt; label;); }; $ ("#" + Element) .trigger ('create'); }; $ (Document) .on ("pagecreate", "#one", function () {createComponent ("radio", "radioComponent", radioBtnArray); createComponent ("checkbox", "checkboxComponent", checkBoxArray);}); & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;  

The component is presented relatively, but the problem is that some duplicate components will also be created. If I can make any component either a checkbox or radio, (; or createComponent ("radio", "radioComponent", radioBtnArray); this line createComponent ("checkbox", "checkboxComponent", checkBoxArray) comment and check) Has been provided correctly. / P>

What's wrong with the code in me?

Can anyone recommend the right way to make JQ widgets / components on the fly and advise me what options are given in a quick and good way, Android mobiles make components dynamic or Static components are used ... check the link below

Thanks in advance.

The problem is that you are inserting objects into a control group by category. Then the second call gets 2 control groups with that class and makes the duplicates you are looking at. To do this:

  function createComponent (type, element, data) {var $ cgdiv = $ (div & gt; div data role = "controlgroup" class = "controlGruopDiv"> ; / Div & gt; '); (For I = 0; I & lt; data.length; i ++) {$ cgdiv.append ('& lt; input type = "' + +" type "" name = "'+ type +'" id = "+ + + + + + + +" For "+ + [[+] + '['] '& lt; / label & gt;' + '+'" & gt; Lt; label;}; $ ("#" + element) .mup (). Append ($ cgdiv) .enhanceWithin ();};  

This code creates a control group div in memory , Adds the input, and then adds it to the DOM and increases it.

Here is a


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -