Trabla: js: jQuery public function
Solving:
Create function via
jQuery.myfunction = function( param)
Example:
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
</head>
<body>
<input value="Click Me 1!" type="button" onclick="jQuery.myFunction1('trololo');" >
<input value="Click Me 2!" type="button" onclick="jQuery.myFunction2('trololo');" >
<script>
$(document).ready(function(){
jQuery.myFunction1= function( msg ){
alert( msg );
}
jQuery.myFunction2= function( msg ){
alert( msg );
}
}
</script>
</body>
</html>
Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts
jquery & DataTables: reload(update) table data
Trabla: jquery & DataTables: reload(update) table data
Solving:
$('#MyDataTableID').dataTable().api().ajax.reload();
Solving:
$('#MyDataTableID').dataTable().api().ajax.reload();
jquery & DataTables: custom field rendering (url example )
Trabla: jquery & DataTables: custom field rendering (urls, buttons etc)
DataTables is a plug-in for the jQuery Javascript library - http://datatables.net/
Solving:
Server returns json with postId and authorId.
Custom render functions form correct link and display in table.
$(document).ready(function() {
var server = 'http://mysite.com/index.php';
var postUrl= 'http://mysite.com/post.php?id=';
var authorUrl= 'http://mysite.com/user.php?id=';
function url( path , label ){
return '<a href="' + path + '">' + label + '</a>';
}
var table = $('#table').dataTable( {
"ajax": {
"url":server ,
"data": function ( d ) {
d.type = 'json';
}
},
"columns": [
{ "data": "postId" },
{ "data": "title" },
{ "data": "description" },
{ "data": "authorId" }
],
"columnDefs": [
{
"render": function ( data, type, row ) {
return url( postUrl + data, data);
},
"targets": 0 //column postId
},
{
"render": function ( data, type, row ) {
return url( authorUrl+ data , data);
},
"targets": 3 //column authorId
}
]
} );
} );
DataTables is a plug-in for the jQuery Javascript library - http://datatables.net/
Solving:
Server returns json with postId and authorId.
Custom render functions form correct link and display in table.
$(document).ready(function() {
var server = 'http://mysite.com/index.php';
var postUrl= 'http://mysite.com/post.php?id=';
var authorUrl= 'http://mysite.com/user.php?id=';
function url( path , label ){
return '<a href="' + path + '">' + label + '</a>';
}
var table = $('#table').dataTable( {
"ajax": {
"url":server ,
"data": function ( d ) {
d.type = 'json';
}
},
"columns": [
{ "data": "postId" },
{ "data": "title" },
{ "data": "description" },
{ "data": "authorId" }
],
"columnDefs": [
{
"render": function ( data, type, row ) {
return url( postUrl + data, data);
},
"targets": 0 //column postId
},
{
"render": function ( data, type, row ) {
return url( authorUrl+ data , data);
},
"targets": 3 //column authorId
}
]
} );
} );
Subscribe to:
Posts (Atom)