Difference between revisions of "Webeshoppin"

From Wiki2
(Replaced content with "===log=== *workin on webeshppin.js#joinexist line 91? what to do based on exists. *var cookieList = function(cookieName) {} has been changed only in lists.js")
Line 2: Line 2:
*workin on webeshppin.js#joinexist line 91? what to do based on exists.
*workin on webeshppin.js#joinexist line 91? what to do based on exists.
*var cookieList = function(cookieName) {} has been changed only in lists.js
*var cookieList = function(cookieName) {} has been changed only in lists.js
===Jquery-Mobile questions===
====[jqm] How can I grab the searchValue?====
If no items match the searchValue I want to add that searchValue to a list.
My plan is to somehow monitor the when the visible matches goes to 0 then grab the value in the filter box.
Here is my test code (it has all it needs to run) I've got the callback function part wrong.
<pre>    <!DOCTYPE html>
    <html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.css" />
        <script src="http://code.jquery.com/jquery.js"></script>
        <script src="http://code.jquery.com/mobile/latest/jquery.mobile.js"></script>
        <script>
        $('#thelists').live('pageinit', function(event) {
        $('body').on('click', "#getdata", function (e) {
            e.stopImmediatePropagation();
            e.preventDefault();
            visib = $("#mylist li:visible").length;
            console.log('list has ' + visib +  ' elements left');
            $("#mylist").listview('option', 'filterCallback', myFilterFunction);
        }); 
          function myFilterFunction( text, searchValue ){
          console.log('Searching for ' + searchValue);
  return text.toLowerCase().indexOf( searchValue ) === -1;
};
});
        </script>             
    </head>
    <body>
        <div id="thelists" data-role="page">
       
            <div data-role="header">
                <h1>My Title</h1>
            </div><!-- /header -->     
            <div data-role="content">
            <a href="index.html" id="getdata" data-role="button">getSearchTxt</a>
<div class="content-primary">
<ul id="mylist" data-role="listview" data-filter="true">
<li><a href="index.html">Acura</a></li>
<li><a href="index.html">Audi</a></li>
<li><a href="index.html">Aukervile</a></li>
<li><a href="index.html">Auadillac</a></li>
<li><a href="index.html">Chrysler</a></li>
<li><a href="index.html">Dodge</a></li>
<li><a href="index.html">Ferrari</a></li>
<li><a href="index.html">Foraud</a></li>
<li><a href="index.html">GMC</a></li>
<li><a href="index.html">Honda</a></li>
<li><a href="index.html">Hyundai</a></li>
<li><a href="index.html">Infiniti</a></li>
<li><a href="index.html">Jeep</a></li>
<li><a href="index.html">Kia</a></li>
</ul>
</div>
            </div><!-- /content -->
        </div><!-- /page -->
    </body>
    </html></pre>
=====ANSWER: Detect the keyup event of the searchbox=====
<pre>
$("input[data-type='search']").keyup(function() {
//$("input[data-type='search']").keyup(function() {
    var optCount = $("#mylist > li:visible").size();
   
    if(optCount < 1) {
        alert('Value: '+$(this).val());
    }
});
</pre>
====[jqm] How do you add an element programmatically with all the css?====
=====ANSWER: Add all the classes to it that you see in developer tools elements.=====
See http://10.0.1.18/webeshoppin/stuff2get/zmisc/add2form.html
====How do you access an element enclosing the active element? ====
will traverse upward and return the nearest selector provided. http://api.jquery.com/closest/
<pre>$("a.removerow").click(function(e){
    $(this).closest('tr').hide();
    e.preventDefault();
});</pre>
=====ANSWER: Use Query's closest(selector) function=====
====[jqm] How do you force a refresh after a page move?====
method1
location.href= 'food2buy.html?repo=' + rep + '&list=' + lis;
method2 (data-ajax="false")
<pre>
$('#allyourlists').append('<li><a href="food2buy.html?repo=' + rep +
  '&list=' + lis + '" data-ajax="false" >Repo: ' + rep + '& List: ' +
  lis + '</a></li>');
</pre>
=====ANSWER: use location.href or data-ajax="false"=====
Why doesn't the clich
http://10.0.1.18/webeshoppin/stuff2get/zmisc/buttonnotfiring.html
====[js] How do you set value of arrays?====
<pre>var myCars=new Array(); // regular array (add an optional integer
myCars[0]="Saab";      // argument to control array's size)
myCars[1]="Volvo";
myCars[2]="BMW";
2:
var myCars=new Array("Saab","Volvo","BMW"); // condensed array
3:
var myCars=["Saab","Volvo","BMW"]; // literal array</pre>
=====ANSWER: [] or new Array()=====
====[jqm] Why is the button not firing?====
http://10.0.1.18/webeshoppin/stuff2get/zmisc/buttonnotfiring2.html
======this works======
:BTW shoudn't use id for multiple items
<pre>        <script>
        //Why is delete button not firing?
        $('#thelists').bind('pageinit', function(event) {
            console.log('in bind pageinit for yourlists');
            var thelists = ["list1", "list2"];
            console.log(thelists);
            $.each(thelists, function(index, alist) {
                $('#allyourlists').append('<li><a href="index.html" data-role="button" id="delalist">List: ' + alist + '</a></li>');
            });
            $('#allyourlists').listview('refresh');
        });
       
        //gets the val of val1 from the previois call
        $('body').on('click', "#delalist", function (e) {
            e.stopImmediatePropagation();
            e.preventDefault();
            alert ('in delalist') ;
        }); 
           
        </script>
</pre>
======this doesn't======
<pre>
      <script>
        //Why is delete button not firing?
        $('#thelists').bind('pageinit', function(event) {
            console.log('in bind pageinit for yourlists');
            var thelists = ["list1", "list2"];
            console.log(thelists);
            $.each(thelists, function(index, alist) {
                $('#allyourlists').append('<li><a href="index.html" data-role="button" id="delalist">List: ' + alist + '</a></li>');
            });
            $('#allyourlists').listview('refresh');
        });
       
        //gets the val of val1 from the previois call
        $("#delalist").click(function (e) {
            e.stopImmediatePropagation();
            e.preventDefault();
            alert ('in delalist') ;
        }); 
           
        </script></pre>
=====ANSWER: Use $('body').on('click', "#delalist", function (e) {=====

Revision as of 10:49, 1 February 2012

log

  • workin on webeshppin.js#joinexist line 91? what to do based on exists.
  • var cookieList = function(cookieName) {} has been changed only in lists.js