Here is my page:
<!DOCTYPE html>
<html>
<head>
<title>Loading from DB</title>
<link rel="stylesheet" href="codebase/webix.css" type="text/css">
<script src="codebase/webix.js" type="text/javascript"></script>
</head>
<body>
<?php
$filename = getcwd() . "/test.txt";
echo $filename;
$line_i_am_looking_for = 5;
$lines = file( $filename , FILE_IGNORE_NEW_LINES );
$lines[$line_i_am_looking_for] = '6my modified line';
file_put_contents( $filename , implode( "\n", $lines ) );
?>
<div class='header_comment'>Test Button</div>
<div id="testB" style='height:600px'></div>
<hr>
<script type="text/javascript" charset="utf-8">
webix.ready(function(){
gridb = webix.ui({
container:"testB",
"view": "form",
"elements": [
{
"view": "textarea",
"name": "woNumber",
"label": "",
"width": 300,
"height": 200,
"options": [
"onViewResize"
],
"value": "",
"placeholder": "WO number (separate with comma if several)",
"labelPosition": "top"
},
{
"view": "button",
"name": "getWODetails",
"label": "",
"value": "Submit",
"options": [
"autowidth:true"
],
on:{
onItemClick:function(id){
webix.message("Test");
}
},
"labelPosition": "top"
},
{
"view": "button",
"name": "getWODetails",
"label": "",
"value": "Passss",
"options": [
"autowidth:true"
],
on:{
onItemClick:function($filename){
webix.message($filename);
}
},
"labelPosition": "top"
}
]
});
});
</script>
</body>
</html>
Now, I am trying to add below code to function to be able to add some string while pressing Passss button:
$filename = getcwd() . "/test.txt";
echo $filename;
$line_i_am_looking_for = 5;
$lines = file( $filename , FILE_IGNORE_NEW_LINES );
$lines[$line_i_am_looking_for] = '6my modified line';
file_put_contents( $filename , implode( "\n", $lines ) );
But if I am doing it like below sample it doesnt work:
on:{
onItemClick:function($filename){
$filename = getcwd() . "/test.txt";
echo $filename;
$line_i_am_looking_for = 5;
$lines = file( $filename , FILE_IGNORE_NEW_LINES );
$lines[$line_i_am_looking_for] = '6my modified line';
file_put_contents( $filename , implode( "\n", $lines ) );
}
Is there any clue how to achieve that?
You need to call a server side script from button's click. Something like next
on:{
onItemClick:function(){
webix.ajax().post("save.php");
}
}
and now, in save.php you can place the necessary logic.
If necessary, you can send an extra parameters to the server side, by using second parameter of webix.ajax.post
on:{
onItemClick:function(){
//will be $_POST["some"] on a server-side
webix.ajax().post("save.php", { some: this.getValue() });
}
}