Difference between revisions of "Jquery"

From Wiki2
(Created page with "<code> $("#quesfrom").autocomplete({ source: function(request, response) { $.getJSON("../tm/smcompl.php", { term: extractLast(request.term), course: document.g...")
 
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
<code>
====read input char and do something if 13====
$("#quesfrom").autocomplete({
:http://parleyv12/fworks/todomvc/architecture-examples/jquery/
source: function(request, response) {
as part of initialization
$.getJSON("../tm/smcompl.php", {
        bindEvents: function () {
term: extractLast(request.term),
            var list = this.$todoList;
course: document.getElementById("numques").value + 'duck'
            this.$newTodo.on('keyup', this.create);
}, response);
 
//$.getJSON("../tm/smcompl.php", {term: extractLast(request.term)}, response);
the 'keyup produces a key code. This code returns doing nothing until the keyup is 13(return)
},
<source lang="javascript">
</code>
        create: function (e) {
            var $input = $(this);
            var val = $.trim($input.val());
 
            if (e.which !== App.ENTER_KEY || !val) {
                console.log(e.which);
                return;
            }
 
            App.todos.push({
                id: Utils.uuid(),
                title: val,
                completed: false
            });
 
            $input.val('');
            App.render();
        },
</source>
 
====$.post $.get====
<syntaxhighlight lang="javascript">
    $.post("../services/hold.php", {data: holdStr}).done(function(data){
        //alert("Data Loaded: " + data);
    });
</syntaxhighlight>
 
====autocomlete====
You can send more info to the autocomplete script:
:In this case &course:33duck gets appended to the get string going to ../tm/smcompl.php
::from: /assess/combine/createCquiz.html
<syntaxhighlight lang="javascript">
    $("#quesfrom").autocomplete({
        source: function(request, response) {
            $.getJSON("../tm/smcompl.php", {
                term: extractLast(request.term),
                course: document.getElementById("numques").value + 'duck'
            }, response);
        //$.getJSON("../tm/smcompl.php", {term: extractLast(request.term)}, response);
        },
</syntaxhighlight>
===resources===
http://www.codeproject.com/Articles/426013/How-jQuery-works

Latest revision as of 14:54, 3 February 2014

read input char and do something if 13

http://parleyv12/fworks/todomvc/architecture-examples/jquery/

as part of initialization

       bindEvents: function () {
           var list = this.$todoList;
           this.$newTodo.on('keyup', this.create);

the 'keyup produces a key code. This code returns doing nothing until the keyup is 13(return) <source lang="javascript">

       create: function (e) {
           var $input = $(this);
           var val = $.trim($input.val());
           if (e.which !== App.ENTER_KEY || !val) {
               console.log(e.which);
               return;
           }
           App.todos.push({
               id: Utils.uuid(),
               title: val,
               completed: false
           });
           $input.val();
           App.render();
       },

</source>

$.post $.get

<syntaxhighlight lang="javascript">

   $.post("../services/hold.php", {data: holdStr}).done(function(data){
       //alert("Data Loaded: " + data);
   });

</syntaxhighlight>

autocomlete

You can send more info to the autocomplete script:

In this case &course:33duck gets appended to the get string going to ../tm/smcompl.php
from: /assess/combine/createCquiz.html

<syntaxhighlight lang="javascript">

   $("#quesfrom").autocomplete({
       source: function(request, response) {
           $.getJSON("../tm/smcompl.php", {
               term: extractLast(request.term),
               course: document.getElementById("numques").value + 'duck'
           }, response);
       //$.getJSON("../tm/smcompl.php", {term: extractLast(request.term)}, response);
       },

</syntaxhighlight>

resources

http://www.codeproject.com/Articles/426013/How-jQuery-works