我想检测新div
元素的插入仅作为父元素的直接子元素div
.
例:
<div id="parent">
<div id="child1"></div>
<div id="child2"></div>
<div id="newChild">I want this element to be detected</div>
</div>
Run Code Online (Sandbox Code Playgroud)
该DOMNodeInserted()
事件对我来说不是一个解决方案,因为它是在每个元素插入时触发的,而不仅仅是孩子.
喜欢:
<div id="parent">
<div id="child1">
<span>I don't want this new element to be detected</span>
</div>
<div id="child2"></div>
<div id="child3"></div>
</div>
Run Code Online (Sandbox Code Playgroud) 我在使用Spring,Spring Data JPA,Spring Security,Primefaces的项目中工作......
我正在学习关于使用spring的动态数据源路由的本教程.
在本教程中,您只能在预定义的数据源之间实现动态数据源切换.
这是我的代码片段:
springContext-jpa.xml
<bean id="dsCgWeb1" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="${jdbc.driverClassName.Cargest_web}"></property>
<property name="url" value="${jdbc.url.Cargest_web}"></property>
<property name="username" value="${jdbc.username.Cargest_web}"></property>
<property name="password" value="${jdbc.password.Cargest_web}"></property>
</bean>
<bean id="dsCgWeb2" class="org.apache.commons.dbcp.BasicDataSource">
// same properties, different values ..
</bean>
<!-- Generic Datasource [Default : dsCargestWeb1] -->
<bean id="dsCgWeb" class="com.cargest.custom.CargestRoutingDataSource">
<property name="targetDataSources">
<map>
<entry key="1" value-ref="dsCgWeb1" />
<entry key="2" value-ref="dsCgWeb2" />
</map>
</property>
<property name="defaultTargetDataSource" ref="dsCgWeb1" />
</bean>
Run Code Online (Sandbox Code Playgroud)
我想要做的是使targetDataSources地图动态与其元素相同.
换句话说,我想获取某个数据库表,使用该表中存储的属性来创建我的数据源,然后将它们放在像targetDataSources这样的地图中.
有没有办法做到这一点 ?
我在我的一个应用程序片段中使用 ViewPager / FragmentPagerAdapter 在每个页面中显示不同的列表视图(见下图):
问题是,在我更改当前视图(片段)并再次重新打开它后,列表视图未呈现(见下图):
行为是随机的,有时当我在不同的选项卡/页面之间滑动时会显示列表视图。
这是我的片段代码:
public class AstucesFragment extends Fragment implements ActionBar.TabListener {
ActionBar actionBar;
AppSectionsPagerAdapter mAppSectionsPagerAdapter;
ViewPager mViewPager;
public static String[] tabslist = new String[5];
public AstucesFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_astuces, container, false);
tabslist[0] = getActivity().getResources().getString(R.string.astuces_quotidien);
tabslist[1] = getActivity().getResources().getString(R.string.astuces_resto);
tabslist[2] = getActivity().getResources().getString(R.string.astuces_loisirs);
tabslist[3] = getActivity().getResources().getString(R.string.astuces_transports);
tabslist[4] = getActivity().getResources().getString(R.string.astuces_tous);
mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getActivity().getSupportFragmentManager());
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
mViewPager = (ViewPager) view.findViewById(R.id.astuces_pager); …
Run Code Online (Sandbox Code Playgroud)