Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-2603

unlisten model listener when the component has detached, and listen it again when attached.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 7.0.6
    • Component/s: None
    • Labels:
      None

      Description

      This issue may affect to all components who have model listener.
      For example,

      <zk>
      
      	<zscript><![CDATA[
      	ListModelList mymodel = new ListModelList();
      	mymodel.add("aaa");
      	mymodel.add("bbb");
      	mymodel.add("ccc");
      	public class MyListbox extends Listbox {
      		public void onInitRender() {
      			super.onInitRender();
      			Clients.log("init " + this.getId());
      		}
      	}
      ]]>
      	</zscript>
      	<label multiline="true">
      	1. you should see "init list1" and "init list2"
      	2. click the "detach" button, you should see only "init list1" is added.
      	3. click the "attach" button, you should see "init list1" and "init list2" are added.
      	 and the content of both listbox are "abc"
      	</label>
      	<listbox id="list1" model="${mymodel}" use="MyListbox">
      		<template name="model">
      			<listitem>
      				<listcell label="${each}" />
      			</listitem>
      		</template>
      	</listbox>
      
      	<listbox id="list2" model="${mymodel}" use="MyListbox">
      		<template name="model">
      			<listitem>
      				<listcell label="${each}" />
      			</listitem>
      		</template>
      	</listbox>
      	<button label="detach">
      		<attribute name="onClick">
      	Component list2 = list2;
      	list2.detach();
      	mymodel.clear();
      	mymodel.add("ddd");
      	mymodel.add("eee");
      	mymodel.add("fff");
      </attribute>
      	</button>
      	<button label="attach">
      		<attribute name="onClick">
      	list2.setPage(self.getPage());
      	mymodel.clear();
      	mymodel.add("abc");
      	mymodel.add("abc");
      	mymodel.add("abc");
      </attribute>
      	</button>
      </zk>
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              ChunfuChang ChunfuChang
              Reporter:
              jumperchen jumperchen
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: