{"id":1871,"date":"2015-01-13T12:45:13","date_gmt":"2015-01-13T10:45:13","guid":{"rendered":"http:\/\/hasselba.ch\/blog\/?p=1871"},"modified":"2015-01-13T12:45:13","modified_gmt":"2015-01-13T10:45:13","slug":"yii-gridviews-selectionchanged-not-working-on-ios","status":"publish","type":"post","link":"https:\/\/hasselba.ch\/blog\/?p=1871","title":{"rendered":"Yii: GridView&#8217;s selectionChanged not working on iOS"},"content":{"rendered":"<p>I had a strange issue with <a title=\"getyiistrap.com: GridView\" href=\"http:\/\/www.getyiistrap.com\/site\/widgets#gridview\" target=\"_blank\">TbGridView<\/a>&#8217;s (<a title=\"getyiistrap.com\" href=\"http:\/\/www.getyiistrap.com\/\" target=\"_blank\">YiiStrap<\/a>&#8217;s version of <a title=\"yiiframework: CGridView\" href=\"http:\/\/www.yiiframework.com\/doc\/api\/1.1\/CGridView\" target=\"_blank\">CGridView<\/a>) <em>selectionChanged<\/em> event: In all browsers, the defined function was executed when a row was selected, but not on devices with iOS 7 &amp; 8.<\/p>\n<p>While trying to hack around the issue, I found a simple solution by adding<\/p>\n<pre><code>'htmlOptions' =&gt; array( 'onclick' =&gt; '' )<\/code><\/pre>\n<p>to the declaration of the grid. This little hack kills the inherited event handler from the body element by adding an empty onclick event to the generated &lt;div&gt;:<\/p>\n<pre><code>&lt;div class=\"grid-view\" id=\"yw0\" onclick=\"\"&gt;<\/code><\/pre>\n<p>Now everything works accross all browsers and devices.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I had a strange issue with TbGridView&#8217;s (YiiStrap&#8217;s version of CGridView) selectionChanged event: In all browsers, the defined function was executed when a row was selected, but not on devices with iOS 7 &amp; 8. While trying to hack around &hellip; <a href=\"https:\/\/hasselba.ch\/blog\/?p=1871\">Weiterlesen <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[62,100],"class_list":["post-1871","post","type-post","status-publish","format-standard","hentry","category-yii","tag-php","tag-yii"],"_links":{"self":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1871","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1871"}],"version-history":[{"count":2,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1871\/revisions"}],"predecessor-version":[{"id":1873,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1871\/revisions\/1873"}],"wp:attachment":[{"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1871"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1871"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasselba.ch\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1871"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}