adding ajax function that is stored in the window object for global access
authorAnthony Talarico <talarico@gaslightmedia.com>
Fri, 26 Oct 2018 20:42:33 +0000 (16:42 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Fri, 26 Oct 2018 20:42:33 +0000 (16:42 -0400)
views/admin/common/components/checkbox.html
views/admin/common/manageDashboard/index.html

index a8d93d7..a32f09c 100644 (file)
@@ -1,16 +1,8 @@
-Checkbox template: <br>
+<div>Checkboxes</div>
 
 <label>
-    <input  type="checkbox" 
-            name="{$component.id}"/>
+    <input  type="checkbox" name="{$component.id}" class="glm-admin-search-field"/>
     <span>{$component.displayName}</span>
 </label>
 
-<script>
-    if ( localStorage.getItem("{$component.id}") ) {
-        console.log("yeah on {$component.id}");
-       //  ${'[name="{$component.id}"]'}.attr("checked", true);
-    } else {
-        console.log("no localstorage item for {$component.id}");
-    }
-</script>
\ No newline at end of file
+<script></script>
index ef601d1..4aaaa75 100644 (file)
@@ -5,14 +5,15 @@
         {foreach $searchFields.components as $component}
             
             {if isset($component.template)}
-                
+               
                 {if "{$smarty.current_dir}/../components/{$component.template}.html"|is_file}
                     {include file="../components/{$component.template}.html"}
                 {else}
                     Failed loading {$smarty.current_dir}/../components/{$component.template}.html
                 {/if}
+               
             {/if}
-            <br>
+
         {/foreach}
     </div>
     <div id="glm-admin-member-list" class="row admin-member-list">
     </div>
 </div>
 <script>
+    
     jQuery(function($){
-            let searchResults   = {};
-            let imageUrl        = `{$glmPluginMediaUrl}/images`
-            let data            = {
-                action      : 'glm_members_admin_ajax',
-                glm_action  : 'adminSearch',
-                // table       : textSearchData.table,
-                // fields      : textSearchData.fields,
-                // where       : textSearchData.where
+        window.Glma = {  
+            adminSearch: function(data){
+                $.ajax({
+                    dataType: "json",
+                    type : 'POST',
+                    url: '{$ajaxUrl}',
+                    data: data,
+                    complete: $("#glm-admin-search-overlay").fadeOut('slow'),
+                    success: function(data) {
+                        data.searchData.forEach( function(value, index){
+                            $("<div />", {
+                                text    : value,
+                                class   : "glm-list-result"
+                            }).appendTo( $("#glm-admin-member-list"));
+                        })
+                    }
+                });
             }
-            
-            $.ajax({
-                dataType: "json",
-                type : 'POST',
-                url: '{$ajaxUrl}',
-                data: data,
-                complete: $("#glm-admin-search-overlay").fadeOut('slow'),
-                success: function(data) {
-                    data.searchData.forEach( function(value, index){
-                        $("<div />", {
-                            text    : value,
-                            class   : "glm-list-result"
-                        }).appendTo( $("#glm-admin-member-list"));
-                    })
-                }
-            });
-        });
-</script>
-
-
+        };
 
-<script> 
 
     /*
         *  Init Materialize collapsible
         });
     }
             
+
+
+    
+    
+        let data = {
+            action      : 'glm_members_admin_ajax',
+            glm_action  : 'adminSearch',
+            // table       : textSearchData.table,
+            // fields      : textSearchData.fields,
+            // where       : textSearchData.where
+        }
+        window.Glma.adminSearch(data);
+
+        $(".glm-admin-search-field").on("change", function(){
+            console.log( $(this) );
+            window.Glma.adminSearch(data);
+        })
+});
 </script>
 
 {include file='admin/footer.html'}
\ No newline at end of file