

<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jsplumb &#8211; Max的程式語言筆記</title>
	<atom:link href="https://stackoverflow.max-everyday.com/tag/jsplumb/feed/" rel="self" type="application/rss+xml" />
	<link>https://stackoverflow.max-everyday.com</link>
	<description>我要當一個豬頭，快樂過每一天</description>
	<lastBuildDate>Wed, 22 Feb 2023 02:24:49 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.1</generator>

<image>
	<url>https://stackoverflow.max-everyday.com/wp-content/uploads/2017/02/max-stackoverflow-256.png</url>
	<title>jsplumb &#8211; Max的程式語言筆記</title>
	<link>https://stackoverflow.max-everyday.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Creating a div element in jQuery</title>
		<link>https://stackoverflow.max-everyday.com/2023/02/creating-a-div-element-in-jquery/</link>
					<comments>https://stackoverflow.max-everyday.com/2023/02/creating-a-div-element-in-jquery/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Tue, 14 Feb 2023 02:02:28 +0000</pubDate>
				<category><![CDATA[javascript筆記]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[jsplumb]]></category>
		<guid isPermaLink="false">https://stackoverflow.max-everyday.com/?p=4329</guid>

					<description><![CDATA[想在 jsplumb 裡動態新增視窗, 原來只需...]]></description>
										<content:encoded><![CDATA[
<p>想在 jsplumb 裡動態新增視窗, 原來只需要新建一個 div node, 指定 classname 與 id 後, append 進去 parent node 就可以了. </p>



<p>You can use&nbsp;<code>append</code>&nbsp;(to add at last position of parent) or&nbsp;<code>prepend</code>&nbsp;(to add at fist position of parent):</p>



<pre class="wp-block-code"><code>$('#parent').append('&lt;div&gt;hello&lt;/div&gt;');    
// or
$('&lt;div&gt;hello&lt;/div&gt;').appendTo('#parent');
</code></pre>



<p>Alternatively, you can use the&nbsp;<code>.html()</code>&nbsp;or&nbsp;<code>.add()</code>&nbsp;as mentioned.</p>



<pre class="wp-block-code"><code>div = $("&lt;div&gt;").html("Loading......");
$("body").prepend(div);    </code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>Technically&nbsp;<code>$('&lt;div&gt;&lt;/div&gt;')</code>&nbsp;will &#8216;create&#8217; a&nbsp;<code>div</code>&nbsp;element (or more specifically a DIV DOM element) but won&#8217;t add it to your HTML document. You will then need to use that in combination with the other answers to actually do anything useful with it (such as using the&nbsp;<code>append()</code>&nbsp;method or such like).</p>



<p>The&nbsp;<a href="http://docs.jquery.com/Manipulation">manipulation documentation</a>&nbsp;gives you all the various options on how to add new elements.</p>



<pre class="wp-block-code"><code>d = document.createElement('div');
$(d).addClass(classname)
    .html(text)
    .appendTo($("#myDiv"))
.click(function () {
    $(this).remove();
})
);</code></pre>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>Example 2:<br><a href="https://stackoverflow.com/questions/867916/creating-a-div-element-in-jquery">https://stackoverflow.com/questions/867916/creating-a-div-element-in-jquery</a></p>



<p><strong><br>If you are using Jquery &gt; 1.4, you are best of with&nbsp;<a href="https://stackoverflow.com/a/4158203/3025256">Ian&#8217;s answer</a>. Otherwise, I would use this method:</strong></p>



<p>This is very similar to&nbsp;<a href="https://stackoverflow.com/a/6976126/3025256">celoron&#8217;s answer</a>, but I don&#8217;t know why they used&nbsp;<code>document.createElement</code>&nbsp;instead of Jquery notation.</p>



<pre class="wp-block-code"><code>$("body").append(function(){
        return $("&lt;div/&gt;").html("I'm a freshly created div. I also contain some Ps!")
            .attr("id","myDivId")
            .addClass("myDivClass")
            .css("border", "solid")                 
            .append($("&lt;p/&gt;").html("I think, therefore I am."))
            .append($("&lt;p/&gt;").html("The die is cast."))
});

//Some style, for better demonstration if you want to try it out. Don't use this approach for actual design and layout!
$("body").append($("&lt;style/&gt;").html("p{background-color:blue;}div{background-color:yellow;}div&gt;p{color:white;}"));
</code></pre>



<p>I also think using&nbsp;<code>append()</code>&nbsp;with a callback function is in this case more readable, because you now immediately that something is going to be appended to the body. But that is a matter of taste, as always when writing any code or text.</p>



<p>In general, use as less HTML as possible in JQuery code, since this is mostly spaghetti code. It is error prone and hard to maintain, because the HTML-String can easily contain typos. Also, it mixes a markup language (HTML) with a programming language (Javascript/Jquery), which is usually a bad Idea.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2023/02/creating-a-div-element-in-jquery/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>how to move jsplumb object position javascript</title>
		<link>https://stackoverflow.max-everyday.com/2023/02/how-to-move-jsplumb-object-position-javascript/</link>
					<comments>https://stackoverflow.max-everyday.com/2023/02/how-to-move-jsplumb-object-position-javascript/#respond</comments>
		
		<dc:creator><![CDATA[max-stackoverflow]]></dc:creator>
		<pubDate>Mon, 13 Feb 2023 09:31:09 +0000</pubDate>
				<category><![CDATA[javascript筆記]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jsplumb]]></category>
		<guid isPermaLink="false">https://stackoverflow.max-everyday.com/?p=4321</guid>

					<description><![CDATA[在使用 jsplumb 時, 透過程式移動了中間...]]></description>
										<content:encoded><![CDATA[
<p>在使用 jsplumb 時, 透過程式移動了中間的windows, 但跟著 windows 的 endpoint 沒有跟著搬家, 如下圖所示, 上面是搬家前, 下圖是搬家後:</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="855" height="1024" src="https://stackoverflow.max-everyday.com/wp-content/uploads/2023/02/2023-02-13-17_06_34-WF-UI-Test-vert.jpg" alt="" class="wp-image-4324" srcset="https://stackoverflow.max-everyday.com/wp-content/uploads/2023/02/2023-02-13-17_06_34-WF-UI-Test-vert.jpg?v=1676280707 855w, https://stackoverflow.max-everyday.com/wp-content/uploads/2023/02/2023-02-13-17_06_34-WF-UI-Test-vert-501x600.jpg?v=1676280707 501w, https://stackoverflow.max-everyday.com/wp-content/uploads/2023/02/2023-02-13-17_06_34-WF-UI-Test-vert-768x920.jpg?v=1676280707 768w" sizes="(max-width: 855px) 100vw, 855px" /></figure>



<p>解法很簡單, 增加下面這一行就行了:</p>



<pre class="wp-block-code"><code>var element = document.getElementById(“xxx”);
element.style.left = newPos.x;
element.style.top = newPos.y;
instance.revalidate(element);</code></pre>



<p>Without your actual code it is difficult to say why elements are misplaced but you can try to repaint the connections after the page loads as the elements might have been moved after initial connection. Include the below code at the end of your JS or after page loads:</p>



<pre class="wp-block-code"><code>jsPlumb.repaintEverything();</code></pre>



<p>資料來源:<br><a href="https://groups.google.com/g/jsplumb/c/AiYcJ6n_4pQ">https://groups.google.com/g/jsplumb/c/AiYcJ6n_4pQ</a></p>



<p>在Google group 上的 jsplumb 社群:<br><a href="https://groups.google.com/g/jsplumb">https://groups.google.com/g/jsplumb</a><br>PS: 這個社區裡的問題, 大多沒有人回覆, 還是到 stackoverflow 上去問比較快. </p>



<p>官方的 jsplumbtoolkit 的說明文件:<br><a href="https://docs.jsplumbtoolkit.com/toolkit/2.x/articles/dragging.html">https://docs.jsplumbtoolkit.com/toolkit/2.x/articles/dragging.html</a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://stackoverflow.max-everyday.com/2023/02/how-to-move-jsplumb-object-position-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
