f0ska

f0ska does not currently provide support for this item.

Popular questions for this item

How to use Select2 with xCRUD?


Select2 initialization code example:

jQuery(document).on("xcrudbeforerequest", function(event, container) {
    if (container) {
        jQuery(container).find("select").select2("destroy");
    } else {
        jQuery(".xcrud").find("select").select2("destroy");
    }
});
jQuery(document).on("ready xcrudafterrequest", function(event, container) {
    if (container) {
        jQuery(container).find("select").select2();
    } else {
        jQuery(".xcrud").find("select").select2();
    }
});
jQuery(document).on("xcrudbeforedepend", function(event, container, data) {
    jQuery(container).find('select[name="' + data.name + '"]').select2("destroy");
});
jQuery(document).on("xcrudafterdepend", function(event, container, data) {
    jQuery(container).find('select[name="' + data.name + '"]').select2();
});


How to make it works on ajax sites or in dynamic content?


There are two methods to make it works with ajax:

1) Write init code into your ajax callback function (after inserting ajax response data in content):

$(document).trigger('xcrudreinit');

2) Add ‘xcrud’ class name to any static parent container on your page, which contains your dynamic data,but can’t be changed by ajax. For testing you can add ‘xcrud’ class name even to <body> tag, but the best if this will be closest static container from dynamically changed content.

But this is not all.
As you know, it is very bad when scripts and styles are loads via ajax. So you must put xcrud’s scripts and styles out of dynamic container. You can do it with load_css() and load_js() methods. Now, see a simple example:
<?php
    include_once('xcrud/xcrud.php');
?>
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>Some page title</title>
    <?php echo Xcrud::load_css(); ?>
</head>
<body>

    <div id="ajax">
        Some dynamic content here
    </div>

    <?php echo Xcrud::load_js(); ?>
</body>
</html>
Do not forget to set $manual_load parameter in xcrud_config.php to true.

Is Xcrud has login / user manager ? Will you create some simple login / auth for Xcrud soon? How I can restrict access to Xcrud?


XCRUD hasn’t login functionality and will never had.
You must protect your pages with login system where you use Xcrud. You can use any login system you want.
This is CRUD library, not full admin area.
You can use it on your existing page, protected or not protected.
You can create some user management with xcrud, but not login script.
This is the same as create login for slider :) Xcrud works on your pages, like some module or plugin, it is NOT an independent application.

How to get events from Xcrud’s fields and how to do some custom actions with jQuery?


Xcrud uses ajax interface, so you must delegate your events from ”.xcrud” container.
You can add needed attribute to a field with set_attr() method.
Example: lets write sum of two fields in third field
PHP code:

$xcrud = Xcrud::get_instance();
$xcrud->table('example_table');
// set custom ids to get easy selectors for js
$xcrud->set_attr('example_field_1',array('id'=>'fied1'));
$xcrud->set_attr('example_field_2',array('id'=>'fied2'));
$xcrud->set_attr('example_field_3',array('id'=>'fied3'));
echo $xcrud->render();

Now Javascript: you can write it in any of your javascript files or in <script> tag on your page
$(document).ready(function(){
   // event must be delegated from .xcrud
   $(".xcrud").on("keyup","#field1,#field2",function(){ // !important, delegation from static container
      var f1 = parseFloat($("#field1").val());
      var f2 = parseFloat($("#field2").val());
      if(!isNaN(f1) && !isNaN(f2)){
         $("#field3").val(f1+f2);
      }
      else{
         $("#field3").val("");
      }
   });
});

How to implement autocomplete in xCRUD?


You can use any autocomplete plugin with Xcrud.
You can set needed attribute to a target field with method set_attr().
If your plugin does not support dynamic content, you must use xcrudafterrequest event to reinit plugin when content will be changed with Xcrud.
Here an example of autocomplete with jQueryUI without ajax support (jQueryUI already present in Xcrud, so you no need anything more). This will set autocomplete to all Xcrud’s text inputs:

<script type="text/javascript">
jQuery(document).on("ready xcrudafterrequest",function(){
     var availableTags = [
        "ActionScript",
        "AppleScript",
        "Asp",
        "BASIC",
        "C",
        "C++",
        "Clojure",
        "COBOL",
        "ColdFusion",
        "Erlang",
        "Fortran",
        "Groovy",
        "Haskell",
        "Java",
        "JavaScript",
        "Lisp",
        "Perl",
        "PHP",
        "Python",
        "Ruby",
        "Scala",
        "Scheme" 
    ];
    jQuery(".xcrud-input[type='text']").autocomplete({
        source: availableTags
    });
});
</script>

See more about jQueryUI Autocomplete

Show more

by
by
by
by
by
by