But there is the question.
Keep the tree in MySQL and editing need to send there data. How do you
manage this? Long tormented himself - now writing to you ...
If possible give an example, it is wonderful!
I would be very happy to answer.
Thank you!
2) Keep persisting changes whenever the user changes something - in
that case - use the callbacks (oncreate, onrename, ondelete, onmove,
etc) and in each of those callbacks make an AJAX call to the server
notifying it about the user action. Then the PHP can modify the
database as needed.
Kindest regards,
Ivan
...
callback : {
onrename : function (NODE) {
NODE.id = id;
$.ajax( {
type: "POST",
url: "ajax_love.php",
data: 'file=' + id + '&rate=' + id,
cache: false,
success: function(html)
{
parent.html(html);
parent.fadeIn(300);
}
});
}
}
....
ajax_love.php:
include("config.php");
$f=$_POST['file'];
$r=0;
$sql_in = "insert into images (img_url,love) values ('$f','$r')";
mysql_query( $sql_in);
....
I so have understood sending does not pass. Or I in general all do not
that?
--
You received this message because you are subscribed to the Google Groups "jsTree" group.
To post to this group, send email to jst...@googlegroups.com.
To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jstree?hl=en.
Data and is not transferred...
Has already omitted hands. The same script of sending/reception of the
data through ajax without jstree works perfectly...
I do not understand in what an error.
Has reduced a script on a maximum
Here a code:
$(function () {
$("#tree").tree({
ui : { theme_name : "default2" },
types : {
"vis" : {
icon : { image : "design/vis.gif" }
},
"unvis" : {
icon : { image : "design/unvis.gif" }
},
"default" : {
renameable : true,
deletable : true,
creatable : true,
draggable : false
}
},
plugins : {
cookie : { prefix : "jstree_" },
contextmenu :
{
items :
{
create : { label : "Создать" },
rename : { label : "Переименовать" },
remove : { label : "Удалить" },
my_act :
{
label : "Сменить видимость",
icon : "vis",
separator_before : true
}
}
}
},
callback : {
onrename : function (NODE) {
var id = NODE.id;
$.ajax( {
type: "POST",
url: "ajax_love.php",
data: { 'file':id },
cache: false,
success: function(html)
{
parent.html(html);
parent.fadeIn(300);
}
});
},
ondblclk : function (NODE) {
document.location.href = $(NODE).children("a:eq(0)").attr
("href");
},
}
});
});
TREE:
<div id="tree">
<ul>
<li rel='unvis' id='6'><a href='123'><ins> </ins>English version</
a></li>
<li rel='unvis' id='1'><a href='123'><ins> </ins>Русская версия</
a><ul>
<li rel='vis' id='32'><a href='#'><ins> </ins>Company profile</
a></li>
<li rel='unvis' id='17'><a href='123'><ins> </ins>On-line опросы</
a></li>
<li rel='unvis' id='61'><a href='123'><ins> </ins>Акции С-П
Групп</a></li>
<li rel='unvis' id='54'><a href='123'><ins> </ins>Архив рассылки</
a></li>
<li rel='unvis' id='20'><a href='123'><ins> </ins>Действующие
акции</a></li>
<li rel='unvis' id='62'><a href='123'><ins> </ins>ДиВиаРиум</a></
li>
<li rel='vis' id='56'><a href='#'><ins> </ins>Доставка</a><ul>
<li rel='vis' id='58'><a href='#'><ins> </ins>Доставка по Москве</
a></li>
<li rel='vis' id='57'><a href='#'><ins> </ins>Доставка по России</
a></li>
<li rel='vis' id='60'><a href='#'><ins> </ins>Обратная связь</a></
li>
<li rel='vis' id='59'><a href='#'><ins> </ins>Получение грузов</
a></li>
</ul>
....
ajax_love.php
$f=$_POST['file'];
$r=0;
$sql_in = "insert into images (img_url,love) values ('$f','$r')";
mysql_query( $sql_in);
Help please!
--
You received this message because you are subscribed to the Google Groups "jsTree" group.
To post to this group, send email to jst...@googlegroups.com.
To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jstree?hl=en.
--
You received this message because you are subscribed to the Google Groups "jsTree" group.
To post to this group, send email to jst...@googlegroups.com.
To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jstree?hl=en.
Thanks you huge for the invaluable help!!!
All that here has been told - works, given-are transferred!!!
2 ivan:
In the first I see so worked plug-in for jquery. Thanks big for fine
operation!
At creation of a new unit through the shortcut menu, the unit forms,
but renaming function does not work.
If separately to rename this unit - all is excellent.
What here it is possible to make?
And still:
Has created a unit - the child flowing, I try to create still same and
it becomes in flowing though they for both should have a same
parent...
Very much I hope for your help!
code:
oncreate : function
(NODE, REF_NODE, TYPE, TREE_OBJ, RB) {
var pi = REF_NODE.id;
var i = NODE.id;
var parent = $("#txt_block");
alert(i); alert(pi);
$.ajax( {
type: "POST",
url: "ajax.php",
data: ({ id:i, par_id:pi, act:'create' }),
cache: false,
success: function(html)
{
parent.html(html);
parent.fadeIn(400);
}
});
},
onrename : function (NODE, TREE_OBJ, RB) {
var i = NODE.id;
var nam = TREE_OBJ.get_text(NODE);
var parent = $("#txt_block");
alert(i);
alert(nam);
$.ajax( {
type: "POST",
url: "ajax.php",
data: ({ id:i, name:nam, act:'rename' }),
cache: false,
success: function(html)
{
parent.html(html);
parent.fadeIn(400);
}
});
},
ondelete : function (NODE) {
var id = NODE.id;
var parent = $("#txt_block");
$.ajax( {
type: "POST",
url: "ajax.php",
data: ({ id:id, act:'delete' }),
cache: false,
success: function(html)
{
parent.html(html);
parent.fadeIn(400);
}
});
}
There was a problem with renaming ущла after its creation...
Help please!....
Really nobody can help? ((((
1. In ajax.php after the creation of know through mysql_insert_id ()
ID of the new element.
2. Sent back through the html in <div style="display: none;">
3. Just give the new item ID from a MySQL database
4. Function renaming works fine!
Everything!
oncreate : function(NODE, REF_NODE, TYPE, TREE_OBJ, RB) {
if(TYPE != "inside") {
TYPE="inside";
REF_NODE = $(NODE).parents("li:eq(0)").get(0);
}
var pi = REF_NODE.id;
var parent = $("#txt_block");
var name = $(NODE).value;
$.ajax( {
type: "POST",
url: "ajax.php",
data: ({ par_id:pi, name:name, act:'create' }),
cache: false,
success: function(html)
{
parent.html(html);
parent.fadeIn(400);
var atr = $('#nomer').text();
$(NODE).attr('id',atr);
}
});
}
ajax.php:
<?PHP
...
switch ($act) {
case 'create':
$sql_in = "insert into sektors (parent_id,visible) values
('$parent_ind','0')";
mysql_query( $sql_in);
$index = mysql_insert_id();
?>
<p style="color: green !important;"> Created | id=<?
php echo $index; ?></p> <div id="nomer" style="display:none;"><?php
echo $index; ?></div>
<?
break;
...
I thank everyone for their support!
Excellent plugin with great functionality and support!
But how can I use it ?
On 21 янв, 15:03, vakata <ivan.bozha...@gmail.com> wrote:
> This is a rather regular question here - there have been 2 or 3
> threads about this one. You have two options:
> 1) save the whole tree to a database at some point (user clicks save,
> or some other event) which is done using the .get method which will
> return the tree in whatever format you need it. And then just post
> that string (remember to convert JSON to a string if JSON is what you
> are using) to the server, where you can use PHP to save the string to
> the database.
Could I save all tree in xml-code ?
Thank you!
--
You received this message because you are subscribed to the Google Groups "jsTree" group.
To post to this group, send email to jst...@googlegroups.com.
To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jstree?hl=en.
$(function () {
$("#xml_n").tree({
data : {
type : "xml_nested",
opts : {
url : "basic_xml_nested_data.xml"
}
}
});
});
var xmlCode=($("#xml_n").get());
it`s only return <b>[object HTMLDivElement]</b>
> Are you populating the tree using xml? If so, calling .get() will return it
> in xml, which you can then save. Otherwise, there are things you can do...
>
> On Mon, Jan 25, 2010 at 10:27 AM, guestlo...@mail.ru <guestlo...@mail.ru>wrote:
>
>
>
>
>
> > Thanks for excellent plugin.
>
> > But how can I use it ?
>
> > On 21 янв, 15:03, vakata <ivan.bozha...@gmail.com> wrote:
> > > This is a rather regular question here - there have been 2 or 3
> > > threads about this one. You have two options:
> > > 1) save the whole tree to a database at some point (user clicks save,
> > > or some other event) which is done using the .get method which will
> > > return the tree in whatever format you need it. And then just post
> > > that string (remember to convert JSON to a string if JSON is what you
> > > are using) to the server, where you can use PHP to save the string to
> > > the database.
>
> > Could I save all tree in xml-code ?
>
> > Thank you!
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "jsTree" group.
> > To post to this group, send email to jst...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > .--
> > For more options, visit this group at
> >http://groups.google.com/group/jstree?hl=en.
>
> --
> John Arrowwood
> John (at) Irie (dash) Inc (dot) com
> John (at) Arrowwood Photography (dot) com
> John (at) Hanlons Razor (dot) com
> --http://www.irie-inc.com/http://arrowwood.blogspot.com/
You received this message because you are subscribed to the Google Groups "jsTree" group.
To post to this group, send email to jst...@googlegroups.com.
To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jstree?hl=en.
On 27 янв, 00:04, John Arrowwood <jarro...@gmail.com> wrote:
> You called .get() on the wrong thing. You need to get the instance of the
> tree (there are several ways of doing this, if you don't know how, consult
> the docs), and call .get() on that. What you did was called .get() on the
> jQuery instance returned by searching for your container. Naturally, that
> won't do what you want it to do.
>
> > <jstree%2Bunsu...@googlegroups.com<jstree%252Bunsubscribe@googlegroups.com>
To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
i have an error
error: (this[0].ownerDocument || this[0]).createDocumentFragment is
not a function
source: http://127.0.0.1:4080/tmp/jstree/lib/jquery.js
string: 12
On Jan 27, 1:45 am, John Arrowwood <jarro...@gmail.com> wrote:
> wrong how? you called yourTree.get() and got what?
>
> > > > <jstree%2Bunsu...@googlegroups.com<jstree%252Bunsubscribe@googlegroups.com>
To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
Thanks a lot.
On 27 янв, 19:31, John Arrowwood <jarro...@gmail.com> wrote:
> You are missing a parameter to your call to .init(). Unfortunately, the
> missing parameters is not mentioned in the docs (Are you listening, Ivan?).
>
> init : function(elem, conf) {
>
> The first parameter to init should be the element that is the container for
> the tree. That is why you got the error you got.
>
<item id="pxml_3" name="hild node 2" link="page.php" title="page
comment"/>
except like
<item id="pxml_3" llink="page.php" title="page comment">
<content><name><![CDATA[Child node 2]]></name></content>
</item>
--
You received this message because you are subscribed to the Google Groups "jsTree" group.
To post to this group, send email to jst...@googlegroups.com.
To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jstree?hl=en.