ȸ¿ø°¡ÀԡžÆÀ̵ð/ºñ¹øã±â
ȨÀ¸·Î


jQuery Mobile ½ÃÀÛÇϽô ºÐµéÀ» À§ÇÑ 10°¡Áö ÆÁ°ú ¿¹Á¦µé...
9³â Àü

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 Àº ÀÌ°ÍÀ» Çϴµ¥ °¡Àå ½¬¿î ¹æ¹ýÀ» ¾Ë·Á ÁÝ´Ï´Ù.

ÃßõÃßõ : 438 Ãßõ ¸ñ·Ï
¹øÈ£ Á¦¸ñ
2,645
php set time limit ÇÔ¼ö - ŸÀӾƿô ¼³Á¤
2,644
Setting .htaccess to allow PHP to be accessed with .xml extension
2,643
jQuery API: Manipulation, Events, Effects, Internals, Utilities
2,642
´Ù¿î·Îµå Ƚ¼ö Á¦ÇÑ ½ºÅ©¸³Æ®
2,641
ÀÚ¹Ù½ºÅ©¸³Æ® ŸÀÌ¸Ó - setTimeout, setInterval, clearInterval ÇÔ¼ö
2,640
jQuery AJAX ·Î±×ÀÎ ±¸Çö
2,639
PHP ¼¼¼Ç ·Î±×ÀÎ ±¸Çö
2,638
PHP ÄíÅ° ·Î±×ÀÎ ±¸Çö
2,637
jQuery¿¡¼­ json º¯¼ö »ç¿ë(È°¿ë)¹ý
2,636
AJAX ¹Ýº¹Ã³¸® ¹× ¼³¸í ¿¹Á¦
2,635
[Android] Intent È°¿ë ¿¹½Ã
2,634
[php] ¹è¿­À» ÀÓÀÇÀÇ ¼ø¼­·Î ¼¯´Â shuffle ÇÔ¼ö
2,633
jQuery API - ¼Ó¼º(CSS), ÃßÃâ
2,632
DIV ¿µ¿ªÀÇ À§Ä¡ ÁöÁ¤ÇÏ´Â ¹æ¹ý°ú ½ºÅ©·Ñ - Àý´ëÀ§Ä¡(absolute), »ó´ëÀ§Ä¡(relative), °íÁ¤À§Ä¡(fixed)
2,631
urlencode(), base64 encode() ÇÔ¼ö
2,630
PHP·Î IE¹öÀü üũÇÏ´Â ¹æ¹ý(Trident°ª»ç¿ë)
2,629
HTML5 °ü·Ã À¯¿ëÇÑ ·¹ÆÛ(ÂüÁ¶) »çÀÌÆ®
2,628
[HTML5] Video & Audio
2,627
HTML5 ¿Àµð¿À °î ¸ñ·Ï Àç»ý
2,626
HTML5 ¿Àµð¿À 404 ¿À·ù½Ã ´Ù¸¥ ÆÄÀÏ Àç»ý
2,625
HTML5 ¿Àµð¿À À̺¥Æ®¸®½º³Ê onerror
2,624
JavaScript Audio °´Ã¼
2,623
HTML5 Audio 2ä³Î Àç»ý
2,622
HTML5 Audio 2ä³Î Àç»ý + Àç»ý¿Ï·á ¸®½º³Ê
2,621
HTML5 À½¾Ç º¼·ý Á¶Àý
2,620
HTML5 À½¾Ç º¼·ý Á¶Àý
2,619
HTML5 ¿Àµð¿À ÀÚµ¿Àç»ý
2,618
HTML5 ¿Àµð¿À ¹Ýº¹ Àç»ý
2,617
HTML5 ¿Àµð¿À À̺¥Æ®¸®½º³Ê
2,616
Ŭ¸¯ ÇѹøÀ¸·Î °íÀ¯ÁÖ¼Ò(URL) º¹»çµÇ°Ô ÇÏ´Â ¹æ¹ý
¸ñ·Ï
¹ÂÁ÷Æ®·ÎÆ® ºÎ»ê±¤¿ª½Ã ºÎ»êÁø±¸ °¡¾ßµ¿ ¤Ó °³ÀÎÁ¤º¸Ãë±Þ¹æħ
Copyright ¨Ï musictrot All rights reserved.