10 handy jQuery mobile tips and snippets to get you started
1. A full basic page
°¡Àå ±âº»ÀÌ µÇ´Â ÆäÀÌÁöÀÇ full mark-up ÀÔ´Ï´Ù. °£´ÜÇÑ single page¸¦ Ç¥ÇöÇϽ÷Á¸é ¿©±â ÀÖ´Â Äڵ尡 °¡Àå ±âº»ÀÌ µÇ´Â °Ì´Ï´Ù.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css"
/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>
</head>
<body>
<div data-role="page" id="home">
<div data-role="header">
<h1>Header</h1>
</div>
<div data-role="content">
<p>Content goes here</p>
</div>
<div data-role="footer">
<h4>Footer</h4>
</div>
</div>
</body>
</html>

2. Where to add traditional jQuery calls
óÀ½ ½ÃÀÛÇÒ ¶§ ¸ð¹ÙÀÏ Ç÷¯±×ÀÎÀÌ trigger µÇ±â Àü¿¡ ¹º°¡ ÇØ¾ß µÇ´Â°Ô ÀÖ´Ù´Â °É ¾Ë°Ô µÆ½À´Ï´Ù. ±âº» jQuery ¸¦ »ç¿ëÇÏ°í ½Í¾ú°Åµç¿ä.
±×·¯¸é ¸ð¹ÙÀÏ plug-inÀ» ÂüÁ¶Çϱâ ÀÌÀü¿¡ jQuery callÀ» ³Ö¾îÁÖ½Ã¸é µË´Ï´Ù. ±×·¯¸é jQuery Mobile º¸´Ù jQuery command°¡
¸ÕÀú ½ÇÇàÀÌ µÇ°ÚÁÒ. ¾Æ·¡¿¡ ±× ÆÐÅÏÀÌ ÀÖ½À´Ï´Ù.
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.css"
/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.min.js"></script>
<script> $(document).ready(function() { // Your jQuery commands go here before the
mobile reference }); </script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a3/jquery.mobile-1.0a3.min.js"></script>

3. Disable AJAX navigation for all links at once
AJAX navigationÀº ¾ÆÁÖ ¸ÚÁöÁÒ. ±×·±µ¥ °¡²û ÀÌ ±â´ÉÀ» disable ½Ãų ÇÊ¿ä°¡ ÀÖÀ» ¶§°¡ ÀÖ¾î¿ä. ÀÌ·² ¶§ AJAX navigationÀ»
»ç¿ëÇÏÁö ¸»µµ·Ï ÇÒ ¼ö °¡ ÀÖ½À´Ï´Ù.
Çì´õºÎºÐ¿¡¼ jQuery mobile library¸¦ reference ÇÑ ÈÄ ¿¡ ¾Æ·¡ ÄÚµùÀ» Ãß°¡ÇØ º¸¼¼¿ä.
jQuery mobile library°¡ ¸ÕÀú load µÇ ÀÖ¾î¾ß ÇÕ´Ï´Ù. ±×·¯´Ï±î ¹Ýµå½Ã ±× ´ÙÀ½¿¡ ³Ö¾î¾ß ÇÕ´Ï´Ù.
<script> $(document).ready(function() { // disable ajax nav $.mobile.ajaxLinksEnabled
= false; }); </script>
¡¡

4. Stop some key items from being truncated
jQuery Mobile libraryÀÇ ±â´É Áß Çϳª´Â ³»¿ëÀÌ ±æ¸é ¾Ë¾Æ¼ UI element¿¡ ¸ÂÃç¼ À߶óÁشٴ °Ì´Ï´Ù.
±×·±µ¥ µÎ°¡Áö °æ¿ì¿¡ ÀÌ·± ±â´ÉÀÌ Á» ºÒÆíÇØ Áú ¶§°¡ ÀÖ´õ¶ó±¸¿ä. ù¹ø°´Â full text¸¦ º¸°í ½ÍÀ» ¶§±¸¿ä. µÎ¹ø°´Â footer text
ÀÔ´Ï´Ù. ÀÌ·±°Íµé¿¡¼ ³»¿ëÀÌ Àß·Á¼ "..."·Î Ç¥½ÃµÇ¸é Á» ±×·¸ÁÒ.
ÀÌ µÎ°¡Áö °æ¿ì¿¡´Â µðÆúÆ®·Î ¾Æ·¡¿Í °°Àº CSS¸¦ ¿À¹ö¶óÀ̵å ÇØ ÁÖ¼¼¿ä.
For list items:
body .ui-li .ui-li-desc {
white-space: normal;
}
For footer content:
body .ui-footer .ui-title {
white-space: normal;
}
5. Use media queries to target devices
ÀÛ¾÷À» ÇÏ¸é¼ ±¸ÇöÇØ¾ß ÇÒ °Í Áß¿¡ Çϳª°¡ °¢ device º°·Î ¾î¶»°Ô µû·Îµû·Î CSS¸¦ ±¸ÇöÇÏ´À³Ä ÀÔ´Ï´Ù. ¿¹¸¦ µé¾î ¾ÆÀÌÆе忡¼´Â 2°³ÀÇ Ä÷³
·¹À̾ƿôÀ» ¾²°í ½Í°í ½º¸¶Æ®Æù¿¡¼´Â ÇÑ°³ÀÇ Ä÷³ ·¹À̾ƿôÀ» ½á¾ß ÇÒ ¶§°¡ ÀÖÀݾƿä.
ÀÌ°ÍÀ» ±¸ÇöÇÏ·Á¸é media queries ¸¦ »ç¿ëÇÏ½Ã¸é µË´Ï´Ù.
ÀÌ ¹Ìµð¾îÄõ¸®¸¦ ÀÌ¿ëÇؼ °¢ ½ºÅ©¸° »çÀÌÁî º° CSS¸¦ ±¸ÇöÇÏ½Ç ¼ö ÀÖ½À´Ï´Ù.
¾Æ·¡ ¸µÅ©¸¦ º¸½Ã¸é µÎ°³ÀÇ ¾ÆÁÖ ÈǸ¢ÇÑ ¾ÆƼŬÀÌ ÀÖ½À´Ï´Ù. ÂüÁ¶Çϼ¼¿ä.
CSS Media Queries
and Using Available Space CSS-Tricks;
Hardboiled CSS3 Media Queries Stuff and Nonsense.
6. Target platforms with jQuery
ƯÁ¤ µð¹ÙÀ̽º¿¡ ƯÁ¤ CSS¸¦ ½ÇÇàÇØ¾ß ÇÒ ¶§°¡ ÀÖÁÒ. ±×¸®°í ¿ÀÁ÷ jQuery ¸¸ »ç¿ëÇØ¾ß µÉ 떄°¡ ÀÖ½À´Ï´Ù. ¿©±â some code from
Snipplr¿¡¼ °¡Á®¿Â Äڵ尡 Àִµ¥¿ä. jQuery ·Î À¯Àú µð¹ÙÀ̽º¿¡ ¸Â°Ô jQueryÀÇ segment portionµéÀ» ½±°Ô »ç¿ëÇÒ ¼ö
ÀÖµµ·Ï ÇÏ´Â ¹æ¹ýÀÔ´Ï´Ù.
var deviceAgent = navigator.userAgent.toLowerCase();
var agentID = deviceAgent.match(/(iphone|ipod|ipad|android)/);
if(agentID.indexOf("iphone")>=0){
alert("iphone");
}
if(agentID.indexOf("ipod")>=0){
alert("ipod");
}
if(agentID.indexOf("ipad")>=0){
alert("ipad");
}
if(agentID.indexOf("android")>=0){
alert("android");
}
7. Use full paths for the targets of form action attributes
One quirk of the library seems to be its difficulty in finding target pages to post
forms to¡¦ that is, unless you use the full path from the root of the website.
For example, I¡¯ve found that this form tag never finds its target:
<form action=" form-handler.php " method="get" >
Whereas a full path like this works as expected:
<form action="/current-directory/form-handler.php" method="get" >
Also, be sure that the results from the form handler produce a full, valid jQuery
mobile page, as shown in tip #1.
8. Create pop-up dialogs
jQuery Mobile libraryÀÇ ÁÁÀº ±â´É Áß Çϳª´Â built-in pop-upÇÏ°í dialog box ±â´ÉÀÌÁÒ. Á¤¸» °£´ÜÇÏ°í ½±°Ô
ÀÌ¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ±âº»ÀûÀ¸·Î data-rel="dialog" ¸¦ ºÙ¿©ÁÖ¸é µË´Ï´Ù.
µÎ°¡Áö¸¸ ±â¾ïÇϼ¼¿ä. ù¹ø°·Î target page´Â ¹Ýµå½Ã full-blown jQuery mobile page¶ó¾ß ÇÕ´Ï´Ù.
µÎ¹ø°´Â Á¦´ë·Î ÀÛµ¿À» Çϵµ·Ï ÇÏ·Á¸éÀº full separate page¶ó¾ß ÇÑ´Ù´Â °Ì´Ï´Ù.
<a href="#pop.html" data-rel="dialog">Pop up!</a>

9. A ¡°Cancel¡± + ¡°Save¡± button combo
µÎ°³ÀÇ ¹öÆ°À» ³ª¶õÈ÷ ³Ö¾î¾ß ÇÒ ¶§°¡ ÀÖÁÒ? ÀÌ·² °æ¿ì´Â fieldset tag¸¦ ¾²½Ã¸é Æí¸®ÇÕ´Ï´Ù.
±×¸®°í µÎ°³ÀÇ ¹öÆ°À» ´Ù¸¥ themeÀ¸·Î Ç¥ÇöÇÒ ¼öµµ ÀÖ½À´Ï´Ù.
ÀÌ ÄÚµå´Â
¿©±â¿¡ Àִ°̴ϴÙ. ÀÚÁÖ ÀÌ¿ëÇϱ⠶§¹®¿¡ Àú°°Àº °æ¿ì´Â µû·Î º¸°üÇØ µ×´Ù°¡ ¾²°í ÀÖ½À´Ï´Ù.
<fieldset>
<div><button type="submit" data-theme="c">Cancel</button></div>
<div><button type="submit" data-theme="b">Submit</button></div>
</fieldset>

¡¡
10. Create a column structure on your own
´Ù¾çÇÑ µð¹ÙÀ̽º¸¦ À§ÇÑ single page structure¿¡ ´ëÇØ À§¿¡¼ ¹Ìµð¾î Äõ¸®¿Í columns¸¦ »ç¿ëÇÏ´Â ¹æ¹ýÀ» À§¿¡¼ ¾Ë·Á µå·ÈÁÒ.
´ÙÇàÈ÷ À¥ °³¹ßÀÚµéÀÌ Ä÷³µéÀ» ¾î¶»°Ô »ç¿ëÇÏ´ÂÁö¿¡ ´ëÇØ ÀÌÀü¿¡ ¸¹ÀÌ ¸¸µé¾î ³ù¾ú½À´Ï´Ù. ÀÌ ±â´ÉµéÀ» ¹Ìµð¾îÄõ¸®¿Í °°ÀÌ ¼¯¾î¾²¸é ÆíÇÏ°ÚÁÒ.
¿ì¸®´Â ´Ù¾çÇÑ ½ºÅ©¸°»çÀÌÁî¿¡ ¸Â°Ô ´Ù¾çÇÑ structure¸¦ ½±°Ô setup ÇÒ ¼ö ÀÖ½À´Ï´Ù.
Position Is Everything Àº ÀÌ°ÍÀ» Çϴµ¥ °¡Àå ½¬¿î ¹æ¹ýÀ» ¾Ë·Á ÁÝ´Ï´Ù.
|